author | Christian Urban <urbanc@in.tum.de> |
Wed, 24 Oct 2018 16:03:07 +0100 | |
changeset 586 | 451a95e1bc25 |
parent 93 | 4794759139ea |
permissions | -rw-r--r-- |
93
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1 |
/* Fibonacci Program |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2 |
input: n |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3 |
*/ |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
4 |
|
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
5 |
n := 19; |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
6 |
minus1 := 0; |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
7 |
minus2 := 1; |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
8 |
while n > 0 do { |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
9 |
temp := minus2; |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
10 |
minus2 := minus1 + minus2; |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
11 |
minus1 := temp; |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
12 |
n := n - 1 |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
13 |
}; |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
14 |
write minus2 |
4794759139ea
better organised
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
15 |