Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
25
Task/Fusc-sequence/Ruby/fusc-sequence.rb
Normal file
25
Task/Fusc-sequence/Ruby/fusc-sequence.rb
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
fusc = Enumerator.new do |y|
|
||||
y << 0
|
||||
y << 1
|
||||
arr = [0,1]
|
||||
2.step do |n|
|
||||
res = n.even? ? arr[n/2] : arr[(n-1)/2] + arr[(n+1)/2]
|
||||
y << res
|
||||
arr << res
|
||||
end
|
||||
end
|
||||
|
||||
fusc_max_digits = Enumerator.new do |y|
|
||||
cur_max, cur_exp = 0, 0
|
||||
0.step do |i|
|
||||
f = fusc.next
|
||||
if f >= cur_max
|
||||
cur_exp += 1
|
||||
cur_max = 10**cur_exp
|
||||
y << [i, f]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
puts fusc.take(61).join(" ")
|
||||
fusc_max_digits.take(6).each{|pair| puts "%15s : %s" % pair }
|
||||
Loading…
Add table
Add a link
Reference in a new issue