- #1
leroyjenkens
- 616
- 49
My program needs to prompt the user to input a number, and using that number, I tell them what number in the Fibonacci sequence their input corresponds to.
So the Fibonacci sequence is 0 1 1 2 3 5 8 13
So if they input the number 6, the program will return "5" as the number in the sequence.
Anyone have any ideas how I would do this? I need a loop for it, I'm sure, and I was trying the "for" loop, but I can't figure out how to just give them the single number in the sequence, and not the whole sequence up to that number.
Thanks.
So the Fibonacci sequence is 0 1 1 2 3 5 8 13
So if they input the number 6, the program will return "5" as the number in the sequence.
Anyone have any ideas how I would do this? I need a loop for it, I'm sure, and I was trying the "for" loop, but I can't figure out how to just give them the single number in the sequence, and not the whole sequence up to that number.
Thanks.