#!/usr/bin/perl use strict; use warnings; sub fib { my $n = shift; return $n if $n < 2; return fib($n - 1) + fib($n - 2); } my $value = 0; my $range = 0; my $phiApprox = 0; my $i = 0; my $temp = 0; my $fibValue1 = 0; my $fibValue2 = 0; print "Fibonnaci Fun\n\n"; print "Pick a number that represents which value of the Fibonnaci sequence you want to start with\n"; print "ie: 1 would be 1 and 2 would 1 and 3 would be 2 and so on.\n"; print "Your choice: "; chomp($value = <>); print "\nNow pick a number to repesent the range you want.\n"; print "If you want to use values 1 through 10 you you need only enter 10,\n"; print "assuming of course you entered 1 above.\n"; print "Your choice: "; chomp($temp = <>); $range = $value + $temp; for($i = $value; $i <= $range; $i++){ $fibValue1 = fib($i); $fibValue2 = fib($i - 1); if($i <= 1){$phiApprox = 0}; if($i >= 2){$phiApprox = $fibValue1 / $fibValue2}; print "\n"; print $fibValue1.' / '.$fibValue2.' = '.$phiApprox; } print "\n";