add while loop calculation of a fibonacci number
This commit is contained in:
parent
a4a66a3041
commit
0473050229
1 changed files with 17 additions and 0 deletions
17
examples/fib.ang
Normal file
17
examples/fib.ang
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
# calculate fibonacci numbers with a loop
|
||||
|
||||
x := 0
|
||||
|
||||
n := 1
|
||||
p := 1
|
||||
|
||||
while x < 100 {
|
||||
f := n + p
|
||||
|
||||
p = n
|
||||
n = f
|
||||
|
||||
write(f)
|
||||
x = x + 1
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue