What is wrong with my Java program?
I'm a beginner and I'm trying to make a program that will calculate the nth Fibonacci number: int n = ...; if (n < 47) { if (n > 0) { if (n != 1) { System.out.println(1); System.out.println(1); int x = 1; int f1 = 1; int f2 = 1; int fn; while (x < n-1) { fn = f1 + f2; f1 = f2; f2 = fn; x = x + 1; } System.out.println(fn); } else System.out.println(1); } else System.out.println("There is no such thing as the " + n + "th Fibonacci number you idiot!"); Where ... is the nth Fibonacci number (so if I want the 5th Fibonacci number, I replace ... with 5). But my program keeps on getting an error. Why???
TELL US , if you have any answer