Last active
July 20, 2017 12:33
-
-
Save aoirint/f04b9f509eab03c370c28ac199d5d6aa to your computer and use it in GitHub Desktop.
Perlでフィボナッチ数列のテスト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub fibo { | |
local($i) = $_[0]; | |
if ($i == 1) { return 0; } | |
if ($i == 2) { return 1; } | |
return &fibo($i-1) + &fibo($i-2); | |
} | |
for (local($i)=1; $i<31; $i++) { | |
print(&fibo($i) . "\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment