Skip to content

Fixes (#3379) #3906

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 115 commits into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
38daad8
Fixes: #{2391}
siddhant2002 Dec 5, 2021
a417229
Fixes #(2391)
siddhant2002 Dec 7, 2021
4cd2497
Merge branch 'TheAlgorithms:master' into master
siddhant2002 Dec 8, 2021
e3c28dc
Delete String_Comparision.java
siriak Dec 9, 2021
0e97ad8
Merge branch 'master' into master
siriak Dec 9, 2021
f27eff4
Fixes: #{2820}
siddhant2002 Dec 14, 2021
bdc2a8a
Merge branch 'TheAlgorithms:master' into master
siddhant2002 Dec 14, 2021
9e77af5
Fixes #{2820}
siddhant2002 Dec 14, 2021
3cacb76
Merge branch 'master' of https://github.com/siddhant2002/Java
siddhant2002 Dec 14, 2021
a192de6
Fixes(#2450)
siddhant2002 Dec 20, 2021
516c7b9
Merge branch 'TheAlgorithms:master' into master
siddhant2002 Dec 20, 2021
10e58e3
string Codes removed
siddhant2002 Dec 21, 2021
c62aea7
Merge branch 'master' into master
siddhant2002 Dec 22, 2021
d24fdf2
fixes(#2882)
siddhant2002 Dec 22, 2021
30615b3
Merge branch 'master' of https://github.com/siddhant2002/Java
siddhant2002 Dec 22, 2021
20261bf
Merge branch 'TheAlgorithms:master' into master
siddhant2002 Jan 18, 2022
f9fc81e
Fixes(2882)
siddhant2002 Jan 19, 2022
86b0102
Merge branch 'master' of https://github.com/siddhant2002/Java
siddhant2002 Jan 19, 2022
f5a0937
Merge branch 'TheAlgorithms:master' into master
siddhant2002 Jan 20, 2022
a214d7f
Merge branch 'TheAlgorithms:master' into master
siddhant2002 Jan 22, 2022
e136a3b
Fixes(#2877)
siddhant2002 Jan 22, 2022
e5541ed
Merge branch 'master' of https://github.com/siddhant2002/Java
siddhant2002 Jan 22, 2022
6220cee
Fixes(#2877)
siddhant2002 Feb 11, 2022
ab73827
Fixes(#2877)
siddhant2002 Feb 12, 2022
17009fc
Merge branch 'TheAlgorithms:master' into master
siddhant2002 Feb 12, 2022
f903458
Fixes(#2877)
siddhant2002 Feb 12, 2022
2467c8c
Merge branch 'master' of https://github.com/siddhant2002/Java
siddhant2002 Feb 12, 2022
ababfa4
Fixes(#2877)
siddhant2002 Feb 13, 2022
255e4df
Fixes(#2877)
siddhant2002 Feb 13, 2022
a404bdc
Fixes(#2873)
siddhant2002 Feb 16, 2022
fd6dd28
Merge branch 'TheAlgorithms:master' into master
siddhant2002 Feb 16, 2022
ddad2bd
Merge branch 'master' into master
siriak Feb 19, 2022
6902ee7
Merge branch 'TheAlgorithms:master' into master
siddhant2002 Feb 19, 2022
3b541ff
Merge branch 'TheAlgorithms:master' into master
siddhant2002 Feb 21, 2022
484d122
Fixes(#2884)
siddhant2002 Feb 22, 2022
08819aa
Merge branch 'master' of https://github.com/siddhant2002/Java
siddhant2002 Feb 22, 2022
26ac95e
Fixes(#2884)
siddhant2002 Feb 22, 2022
5ceffa0
Fixes(#2884)
siddhant2002 Feb 22, 2022
e0c8cc9
Fixes(#2884)
siddhant2002 Feb 22, 2022
31826c0
Fixes(#2884)
siddhant2002 Feb 25, 2022
4b198ea
Merge branch 'TheAlgorithms:master' into master
siddhant2002 Feb 26, 2022
5d1b736
Merge branch 'TheAlgorithms:master' into master
siddhant2002 Mar 14, 2022
8f543e5
Merge branch 'TheAlgorithms:master' into master
siddhant2002 Mar 19, 2022
aa666e3
Merge branch 'TheAlgorithms:master' into master
siddhant2002 Mar 26, 2022
972cf29
Fixes(#2889)
siddhant2002 Mar 26, 2022
cb5eb19
Merge branch 'master' of https://github.com/siddhant2002/Java
siddhant2002 Mar 26, 2022
11575fc
Fixes (#2889)
siddhant2002 Mar 26, 2022
2719938
Fixes(#2889)
siddhant2002 Mar 30, 2022
c26e672
Fixes(#2889)
siddhant2002 Mar 30, 2022
f04d318
Merge branch 'master' into master
siddhant2002 Mar 30, 2022
5bb853b
Fixes(#2889)
siddhant2002 Mar 31, 2022
d406f90
Merge branch 'master' of https://github.com/siddhant2002/Java
siddhant2002 Mar 31, 2022
ecee9f4
Fixes(#2889)
siddhant2002 Mar 31, 2022
d69880e
Fixes(#2889)
siddhant2002 Mar 31, 2022
3609dcb
Merge branch 'master' into master
siriak Apr 6, 2022
72e750d
Fixes (#2957)
siddhant2002 May 4, 2022
d0b0b71
Merge branch 'master' of https://github.com/siddhant2002/Java
siddhant2002 May 4, 2022
13aa7fa
Fixes (#2957)
siddhant2002 May 4, 2022
6becf81
Merge branch 'TheAlgorithms:master' into master
siddhant2002 May 5, 2022
156cbdc
Fixes ('2957)
siddhant2002 May 8, 2022
6b0a0f5
Merge branch 'master' of https://github.com/siddhant2002/Java
siddhant2002 May 8, 2022
9418ff2
Fixes(2957)
siddhant2002 May 8, 2022
6d1f03f
Fixes #3199
siddhant2002 Aug 22, 2022
9c055fc
Merge branch 'master' of https://github.com/siddhant2002/Java
siddhant2002 Aug 22, 2022
4afef8e
(Fixes #3199)
siddhant2002 Aug 22, 2022
1fbf531
Fixes #3199
siddhant2002 Aug 22, 2022
52e089e
Fixes #3199
siddhant2002 Aug 22, 2022
9b144cc
Fixes #3199
siddhant2002 Aug 22, 2022
d068f18
Fixes #3199
siddhant2002 Aug 22, 2022
e67fd7a
Fixes #3199
siddhant2002 Aug 22, 2022
9a44979
Fixes #3199
siddhant2002 Aug 24, 2022
f179ea6
Fixes #3199
siddhant2002 Aug 24, 2022
1b038ef
Fixes #3199
siddhant2002 Aug 24, 2022
b49e155
Merge branch 'TheAlgorithms:master' into master
siddhant2002 Aug 26, 2022
339b685
Fixes (#3194)
siddhant2002 Aug 30, 2022
c1a0f99
Merge branch 'master' of https://github.com/siddhant2002/Java
siddhant2002 Aug 30, 2022
a809a96
Merge branch 'TheAlgorithms:master' into master
siddhant2002 Aug 30, 2022
6b5738a
Fixes #3194
siddhant2002 Aug 30, 2022
a5449f2
Merge branch 'master' of https://github.com/siddhant2002/Java
siddhant2002 Aug 30, 2022
0bb23f7
Fixes #3194
siddhant2002 Aug 31, 2022
a489c78
Fixes '#3194
siddhant2002 Aug 31, 2022
3de902f
Fixes #3194
siddhant2002 Aug 31, 2022
8bbdbdf
Merge branch 'master' into master
siddhant2002 Sep 3, 2022
d35ea67
Merge branch 'TheAlgorithms:master' into master
siddhant2002 Sep 13, 2022
0257b64
Merge branch 'TheAlgorithms:master' into master
siddhant2002 Sep 29, 2022
e237ad3
Merge branch 'TheAlgorithms:master' into master
siddhant2002 Feb 10, 2023
9aa4868
Fixes (#3359)
siddhant2002 Feb 11, 2023
a653810
Fixes(#3359)
siddhant2002 Feb 11, 2023
e04f145
Fixes(#3359)
siddhant2002 Feb 11, 2023
cbad390
Fixes(#3359)
siddhant2002 Feb 11, 2023
7d4e87d
Fixes(#3359)
siddhant2002 Feb 11, 2023
4411faa
Fixes(#3359)
siddhant2002 Feb 11, 2023
d55840a
Fixes(#3359)
siddhant2002 Feb 11, 2023
5736de7
Fixes(#3359)
siddhant2002 Feb 14, 2023
4fba735
Fixes(#3359)
siddhant2002 Feb 14, 2023
1cbbb1a
Merge branch 'master' into master
siddhant2002 Feb 14, 2023
4b761d4
Fixes(#3359)
siddhant2002 Feb 19, 2023
3f0c02f
Fixes(#3359)
siddhant2002 Feb 19, 2023
5cf760c
Merge branch 'master' of https://github.com/siddhant2002/Java
siddhant2002 Feb 19, 2023
9160e54
(Fixes #3359)
siddhant2002 Feb 26, 2023
6ef62a2
(Fixes #3359)
siddhant2002 Feb 26, 2023
b0985d5
(Fixes #3359)
siddhant2002 Feb 26, 2023
b5274ae
(Fixes #3359)
siddhant2002 Feb 26, 2023
3b7595a
(Fixes #3359)
siddhant2002 Feb 26, 2023
65bc15e
(Fixes #3359)
siddhant2002 Feb 26, 2023
8b9f96c
(Fixes #3359)
siddhant2002 Feb 26, 2023
9f50026
(Fixes #3359)
siddhant2002 Feb 28, 2023
269b125
(Fixes #3359)
siddhant2002 Feb 28, 2023
2cd1993
(Fixes #3359)
siddhant2002 Feb 28, 2023
332e219
(Fixes #3359)
siddhant2002 Feb 28, 2023
f99887f
(Fixes #3359)
siddhant2002 Feb 28, 2023
c6b3505
Merge branch 'master' into master
siddhant2002 Feb 28, 2023
edb1656
Merge branch 'TheAlgorithms:master' into master
siddhant2002 Feb 28, 2023
9b28617
(Fixes #3379)
siddhant2002 Mar 1, 2023
68688b6
Merge branch 'master' of https://github.com/siddhant2002/Java
siddhant2002 Mar 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/main/java/com/thealgorithms/maths/FrizzyNumber.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/** Author : Siddhant Swarup Mallick
* Github : https://github.com/siddhant2002
*/

/** Program description - To find the FrizzyNumber*/


package com.thealgorithms.maths;

public class FrizzyNumber {

/**
* Returns the n-th number that is a sum of powers
* of the given base.
* Example: base = 3 and n = 4
* Ascending order of sums of powers of 3 =
* 3^0 = 1, 3^1 = 3, 3^1 + 3^0 = 4, 3^2 + 3^0 = 9
* Ans = 9
*
* @param base The base whose n-th sum of powers is required
* @param n Index from ascending order of sum of powers of base
* @return n-th sum of powers of base
*/
public static double getNthFrizzy(int base, int n) {
double final1 = 0.0;
int i = 0;
do
{
final1 += Math.pow(base, i++) * (n % 2);
} while ((n /= 2) > 0);
return final1;
}
}
48 changes: 48 additions & 0 deletions src/test/java/com/thealgorithms/maths/FrizzyNumberTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.thealgorithms.maths;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;
public class FrizzyNumberTest {
@Test
public void testFrizziesForBase2() {
assertEquals(
1,
FrizzyNumber.getNthFrizzy(2, 1));
assertEquals(
3,
FrizzyNumber.getNthFrizzy(2, 3));
assertEquals(
1000,
FrizzyNumber.getNthFrizzy(2, 1000));
}

@Test
public void testFrizziesForBase3() {
assertEquals(
1,
FrizzyNumber.getNthFrizzy(3, 1));
assertEquals(
3,
FrizzyNumber.getNthFrizzy(3, 2));
assertEquals(
29430,
FrizzyNumber.getNthFrizzy(3, 1000));
}

@Test
public void testFrizziesForBase69() {
assertEquals(
1,
FrizzyNumber.getNthFrizzy(69, 1));
assertEquals(
69,
FrizzyNumber.getNthFrizzy(69, 2));
assertEquals(
328510,
FrizzyNumber.getNthFrizzy(69, 9));
assertEquals(
333340,
FrizzyNumber.getNthFrizzy(69, 15));
}
}