Skip to content

Instantly share code, notes, and snippets.

@cptangry
Last active July 5, 2017 06:13
Show Gist options
  • Save cptangry/7181a49596a0d238679c57baec047907 to your computer and use it in GitHub Desktop.
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
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