Format code with prettier (#3375)

This commit is contained in:
acbin
2022-10-03 17:23:00 +08:00
committed by GitHub
parent 32b9b11ed5
commit e96f567bfc
464 changed files with 11483 additions and 6189 deletions

View File

@ -2,25 +2,23 @@
* 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 nthManShanksPrime(int n , int expected_answer)
{
int a[] = new int[n+1];
public static boolean nthManShanksPrime(int n, int expected_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];
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]==expected_answer;
return a[n] == expected_answer;
// returns true if calculated answer matches with expected answer
}
}
}