Last active
July 5, 2017 06:13
-
-
Save cptangry/7181a49596a0d238679c57baec047907 to your computer and use it in GitHub Desktop.
Çok büyük değerdeki sayıların karşılığı fibonacci dizisi değerini verir ya da o sıraya kadar diziyi listeler
This file contains hidden or 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
PARAM = ARGV[0] | |
SAYI = ARGV[1].to_i | |
def fibo(n) | |
(2..n).reduce([0, 1]) { |bellek| bellek << bellek.last(2).reduce(:+) } | |
end | |
if __FILE__ == $0 | |
case PARAM | |
when '-f' then fibo(SAYI) | |
when '-d' then fibo(SAYI).last | |
else | |
puts "ruby FILENAME -f #SAYI ya da ruby FILENAME -d SAYI\nÖRNEK: ruby dosya_adi.rb -f 15" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment