changeset 178 | d36363d648e3 |
parent 147 | 4725bba8ef26 |
child 182 | 9ce2414e470e |
177:53def1fbf472 | 178:d36363d648e3 |
---|---|
1 /* Fibonnacci sequence implemented in |
|
2 the WHILE language */ |
|
3 |
|
1 write "Input a number "; |
4 write "Input a number "; |
2 read n; |
5 read n; |
3 x := 0; |
6 x := 0; // start values |
4 y := 1; |
7 y := 1; |
5 while n > 0 do { |
8 while n > 0 do { |
6 temp := y; |
9 temp := y; |
7 y := x + y; |
10 y := x + y; |
8 x := temp; |
11 x := temp; |
9 n := n - 1 |
12 n := n - 1 // decrement counter |
10 }; |
13 }; |
11 write "Result "; |
14 write "Result "; |
12 write y |
15 write y |
13 |
16 |