Skip to content

Commit

Permalink
Test fib loop variant
Browse files Browse the repository at this point in the history
  • Loading branch information
Quaqqer committed Jan 6, 2024
1 parent 3ec995b commit ac3fdd8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/saft-tests/res/tests/fib_loop/fib_loop.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3736710778780434371
20 changes: 20 additions & 0 deletions crates/saft-tests/res/tests/fib_loop/fib_loop.saf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
fn fib(n) {
if n == 0 { return 0; };

a := 0;
b := 1;

loop {
if n == 1 {
break b;
};

c := a + b;
a = b;
b = c;

n = n - 1;
}
}

print(fib(100));

0 comments on commit ac3fdd8

Please sign in to comment.