Skip to content

Fixes(#2884) #2955

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 40 commits into from
Feb 26, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 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
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
Prev Previous commit
Next Next commit
Fixes(#2884)
  • Loading branch information
siddhant2002 committed Feb 22, 2022
commit 484d122c8f7d673eb8592fbdd53693c61d651d98
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/** Author : Siddhant Swarup Mallick
* Github : https://github.com/siddhant2002
*/


/** Program description - To find the New Man Shanks Prime. */
/** Wikipedia Link - https://en.wikipedia.org/wiki/Newman%E2%80%93Shanks%E2%80%93Williams_prime */

package com.thealgorithms.dynamicprogramming;

public class NewManShanksPrime {
public static boolean newManShanksPrime(int n , int answer)
{
int a[] = new int[n+1];
// array of n+1 size is initialized
a[0] = a[1] = 1;
// The 0th and 1st index position values are fixed. They are initialized as 1
for(int i=2;i<=n;i++)
{
a[i]=2*a[i-1]+a[i-2];
}
// The loop is continued till n
return a[n]==answer;
// Calculated sum is checked with the expected answer
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.thealgorithms.others;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

import com.thealgorithms.dynamicprogramming.NewManShanksPrime;
public class NewManShanksPrimeTest {
@Test
void testForOneElement()
{
assertTrue(NewManShanksPrime.newManShanksPrime(1,1));
}

@Test
void testForTwoElements()
{
assertTrue(NewManShanksPrime.newManShanksPrime(2,3));
}

@Test
void testForThreeElements()
{
assertTrue(NewManShanksPrime.newManShanksPrime(3,7));
}

@Test
void testForFourElements()
{
assertTrue(NewManShanksPrime.newManShanksPrime(4,17));
}

@Test
void testForFiveElements()
{
assertTrue(NewManShanksPrime.newManShanksPrime(5,41));
}

@Test
void testForSixElements()
{
assertTrue(NewManShanksPrime.newManShanksPrime(6,99));
}

@Test
void testForSevenElements()
{
assertTrue(NewManShanksPrime.newManShanksPrime(7,239));
}

@Test
void testForEightElements()
{
assertTrue(NewManShanksPrime.newManShanksPrime(8,577));
}
}