answersLogoWhite

0

This Perl script should answer your question for any index in the Fibonacci sequence. (until it overflows a variable) sub fib { print "Enter a number: "; chomp($n = ); $x = 1; $y = 1; $ans = 0; $i = $n; while ($i > 0) { $ans = $y; $y = $x; $x += $ans; $i--; } print "\nThe Fibonacci number at index $n is $ans\n"; } &fib; Enter a number: 22 The Fibonacci number at index 22 is 17711 here are the first 20, just add 19 and 20 and you get 21 and add 20 and 21 and you get 22 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765 . .

User Avatar

Wiki User

16y ago

Still curious? Ask our experts.

Chat with our AI personalities

LaoLao
The path is yours to walk; I am only here to hold up a mirror.
Chat with Lao
MaxineMaxine
I respect you enough to keep it real.
Chat with Maxine
ViviVivi
Your ride-or-die bestie who's seen you through every high and low.
Chat with Vivi

Add your answer:

Earn +20 pts
Q: What is 22 Fibonacci number?
Write your answer...
Submit
Still have questions?
magnify glass
imp