in reply to fibonacci numbers using subroutine?
use warnings; use strict; sub { my $x = 0; my $y = 1; my $third = 0; my $count; print "Enter the number you would like to see in the sequence: "; my $number = <STDIN>; for ($count = 1; $count<=$number; $count++) { $third = $x + $y; $x = $y; $y = $third; } print $y; }->();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: fibonacci numbers using subroutine?
by moritz (Cardinal) on Aug 20, 2010 at 08:37 UTC | |
by TimToady (Parson) on Aug 20, 2010 at 18:33 UTC | |
by JavaFan (Canon) on Aug 20, 2010 at 09:11 UTC | |
by moritz (Cardinal) on Aug 20, 2010 at 09:21 UTC | |
by JavaFan (Canon) on Aug 20, 2010 at 09:45 UTC | |
by moritz (Cardinal) on Aug 20, 2010 at 10:19 UTC | |
|