fibonacci
Some checks failed
Build / build (push) Failing after 2m11s
Test / build (push) Failing after 2m10s

This commit is contained in:
Chuck Smith
2024-03-14 20:11:29 -04:00
parent cc78fee3c8
commit 36f04713bd
2 changed files with 90 additions and 10 deletions

View File

@@ -755,3 +755,27 @@ func TestRecursiveFunctions(t *testing.T) {
runVmTests(t, tests)
}
func TestRecursiveFibonacci(t *testing.T) {
tests := []vmTestCase{
{
input: `
let fibonacci = fn(x) {
if (x == 0) {
return 0;
} else {
if (x == 1) {
return 1;
} else {
fibonacci(x - 1) + fibonacci(x - 2);
}
}
};
fibonacci(15);
`,
expected: 610,
},
}
runVmTests(t, tests)
}