Homework 9

Write a program to find the nth number in the Fibonacci sequence where n is entered by the user. Here are the first twenty terms of the Fibonacci sequence:

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181,...

At any point in the series (starting with the second), the next Fibonacci number is the current number plus the previous number. For example, if I have just found the 6th Fibonacci number, the next one (the 7th) is the sum of the current number (the 6th) and the previous number (the 5th).

Your program should allow the user to continue to enter any number of values for n. Terminate the program when the user enters a negative number or a value of zero. Here is a sample run:

Sample Run