Data update
This commit is contained in:
parent
8e4e15fa56
commit
72eb4943cb
1853 changed files with 35514 additions and 9441 deletions
14
Task/Sudan-function/Crystal/sudan-function.cr
Normal file
14
Task/Sudan-function/Crystal/sudan-function.cr
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
def sudan (n, x : UInt64, y : UInt64)
|
||||
if n == 0
|
||||
x + y
|
||||
elsif y == 0
|
||||
x
|
||||
else
|
||||
s = sudan(n, x, y-1)
|
||||
sudan(n-1, s, s + y)
|
||||
end
|
||||
end
|
||||
|
||||
[{0, 0, 0}, {1, 1, 1}, {2, 1, 1}, {2, 2, 1}, {2, 2, 2}, {3, 1, 1}].each do |n, x, y|
|
||||
puts "sudan #{n} (#{x}, #{y}) = #{sudan(n, x.to_u64, y.to_u64)}"
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue