mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-21 02:53:15 +08:00
Format code with prettier (#3375)
This commit is contained in:
@ -22,11 +22,10 @@ public class CatalanNumber {
|
||||
* @return catalanArray[n] the nth Catalan number
|
||||
*/
|
||||
static long findNthCatalan(int n) {
|
||||
|
||||
// Array to store the results of subproblems i.e Catalan numbers from [1...n-1]
|
||||
long catalanArray[] = new long[n + 1];
|
||||
|
||||
// Initialising C₀ = 1 and C₁ = 1
|
||||
// Initialising C₀ = 1 and C₁ = 1
|
||||
catalanArray[0] = 1;
|
||||
catalanArray[1] = 1;
|
||||
|
||||
@ -48,7 +47,9 @@ public class CatalanNumber {
|
||||
public static void main(String[] args) {
|
||||
Scanner sc = new Scanner(System.in);
|
||||
|
||||
System.out.println("Enter the number n to find nth Catalan number (n <= 50)");
|
||||
System.out.println(
|
||||
"Enter the number n to find nth Catalan number (n <= 50)"
|
||||
);
|
||||
int n = sc.nextInt();
|
||||
System.out.println(n + "th Catalan number is " + findNthCatalan(n));
|
||||
|
||||
|
Reference in New Issue
Block a user