2018-04-26 11:33:33 +02:00
|
|
|
require_relative 'helper'
|
|
|
|
|
|
|
|
module Methods
|
|
|
|
class TestFibo < MethodsTest
|
|
|
|
|
2018-04-27 20:56:41 +02:00
|
|
|
def test_count_down
|
|
|
|
run_space <<HERE
|
|
|
|
def down( n )
|
|
|
|
if( n < 2 )
|
|
|
|
return n
|
|
|
|
else
|
|
|
|
a = down(n - 1)
|
|
|
|
return a
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def main(arg)
|
|
|
|
return down(8)
|
|
|
|
end
|
|
|
|
HERE
|
2018-06-19 17:55:47 +02:00
|
|
|
assert_equal 1 , get_return
|
2018-04-27 20:56:41 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def est_fibo
|
2018-04-26 11:33:33 +02:00
|
|
|
run_space <<HERE
|
|
|
|
def fibo_r( n )
|
|
|
|
if( n < 2 )
|
|
|
|
return n
|
|
|
|
else
|
|
|
|
a = fibo_r(n - 1)
|
|
|
|
b = fibo_r(n - 2)
|
|
|
|
return a + b
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def main(arg)
|
|
|
|
return fibo_r(8)
|
|
|
|
end
|
|
|
|
HERE
|
2018-06-19 17:55:47 +02:00
|
|
|
assert_equal 8 , get_return
|
2018-04-26 11:33:33 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|