author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Wed, 05 Dec 2012 04:13:12 +0000 | |
changeset 86 | 6a7fe83820c8 |
parent 84 | 719fd738d2a0 |
permissions | -rw-r--r-- |
80
191daa3ee29e
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
76
diff
changeset
|
1 |
/* Fibonacci Program |
191daa3ee29e
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
76
diff
changeset
|
2 |
input: n |
84
719fd738d2a0
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
83
diff
changeset
|
3 |
*/ |
75
898c25a4e399
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
73
diff
changeset
|
4 |
|
83
bd61b03b9eaa
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
5 |
n := 19; |
75
898c25a4e399
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
73
diff
changeset
|
6 |
minus1 := 0; |
898c25a4e399
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
73
diff
changeset
|
7 |
minus2 := 1; |
80
191daa3ee29e
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
76
diff
changeset
|
8 |
while n > 0 do { |
73
27469183da75
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
9 |
temp := minus2; |
27469183da75
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
10 |
minus2 := minus1 + minus2; |
27469183da75
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
11 |
minus1 := temp; |
27469183da75
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
12 |
n := n - 1 |
75
898c25a4e399
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
73
diff
changeset
|
13 |
}; |
84
719fd738d2a0
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
83
diff
changeset
|
14 |
write minus2 |
75
898c25a4e399
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
73
diff
changeset
|
15 |