Skip to content

Commit 620b365

Browse files
committed
native: fibonacci test
1 parent a045bb0 commit 620b365

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
fn main() {
2+
stop := 10
3+
// Can only calculate correctly until rank 92
4+
if stop > 92 {
5+
println('rank must be 92 or less')
6+
return
7+
}
8+
// Three consecutive terms of the sequence
9+
mut a := i64(0)
10+
mut b := i64(0)
11+
mut c := i64(1)
12+
println(a + b + c)
13+
for _ in 0 .. stop {
14+
// Set a and b to the next term
15+
a = b
16+
b = c
17+
// Compute the new term
18+
c = a + b
19+
// Print the new term
20+
println(c)
21+
}
22+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
1
2+
1
3+
2
4+
3
5+
5
6+
8
7+
13
8+
21
9+
34
10+
55
11+
89

0 commit comments

Comments
 (0)