fibonacci while works just as well now
surprisingly much faster though,
This commit is contained in:
parent
aad50021fe
commit
1309ea37de
@ -7,4 +7,4 @@ require_relative "test_if"
|
||||
require_relative "test_putint"
|
||||
require_relative "test_recursive_fibo"
|
||||
require_relative "test_return"
|
||||
#require_relative "test_while_fibo"
|
||||
require_relative "test_while_fibo"
|
||||
|
@ -9,6 +9,7 @@ class Object
|
||||
int fibonaccit(int n)
|
||||
int a = 0
|
||||
int b = 1
|
||||
n = n - 1
|
||||
while_plus( n )
|
||||
int tmp = a
|
||||
a = b
|
||||
@ -20,12 +21,14 @@ class Object
|
||||
end
|
||||
|
||||
int main()
|
||||
fibonaccit( 10 )
|
||||
return fibonaccit( 10 )
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@length = 5
|
||||
@length = 278
|
||||
check
|
||||
assert_equal Parfait::Message , @interpreter.get_register(:r1).class
|
||||
assert_equal 55 , @interpreter.get_register(:r1).return_value
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user