Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub fibonacci {
- my $n = shift;
- return $n if $n <= 1;
- return fibonacci($n - 1) + fibonacci($n - 2);
- }
- print "Masukkan panjang deret Fibonacci: ";
- my $panjang = <STDIN>;
- chomp($panjang);
- print "Deret Fibonacci: ";
- for (my $i = 0; $i < $panjang; $i++) {
- print fibonacci($i), " ";
- }
- print "\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement