1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-12-23 23:30:22 +00:00
millfork/examples/tests/test_fibonacci.mfk
2020-04-06 00:44:20 +02:00

19 lines
321 B
Plaintext

import framework
word fib(byte n) {
stack byte i
i = n
if i < 2 { return 1 }
return fib(i-1) + fib(i-2)
}
void test_fibonacci() {
start_suite("Fibonacci"z)
assert_equal(1, fib(0))
assert_equal(1, fib(1))
assert_equal(2, fib(2))
assert_equal(3, fib(3))
assert_equal(5, fib(4))
}