author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Wed, 30 Oct 2013 15:14:14 +0000 | |
changeset 172 | 47b5c91eff47 |
parent 147 | 4725bba8ef26 |
child 178 | d36363d648e3 |
permissions | -rw-r--r-- |
147
4725bba8ef26
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
1 |
write "Input a number "; |
4725bba8ef26
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
2 |
read n; |
4725bba8ef26
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
3 |
x := 0; |
4725bba8ef26
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
4 |
y := 1; |
80
191daa3ee29e
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
76
diff
changeset
|
5 |
while n > 0 do { |
147
4725bba8ef26
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
6 |
temp := y; |
4725bba8ef26
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
7 |
y := x + y; |
4725bba8ef26
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
8 |
x := temp; |
4725bba8ef26
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
9 |
n := n - 1 |
75
898c25a4e399
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
73
diff
changeset
|
10 |
}; |
147
4725bba8ef26
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
11 |
write "Result "; |
4725bba8ef26
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
12 |
write y |
75
898c25a4e399
tuned
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
73
diff
changeset
|
13 |