Text: Java Java
Number is the addition of the last 01. The Fibonacci sequence is a series of numbers, starting with 0 and 1. 1, 1, 2, 3, 5, 8, 13, 21, 34, 55. The Fibonacci Sequence
The nth number of the Fibonacci sequence can be calculated with F(n) = (pow(FI, n) - pow(FI_H, n)) / sqrt(5)
Where FI = (1 + sqrt(5)) / 2 and FI_H = (1 - sqrt(5)) / 2.
The program prompts the user to enter the index (n) and calculates the nth number of the Fibonacci sequence with the formula above. It then prints the result as an integer to the console.
To calculate the square root of x, you can use Math.sqrt(x). To calculate x raised to the power of y, you can use Math.pow(x, y).
Enter index: fib(1)
Enter index: 14 fib(14) 377