solutions/cw2/fib.while
author Christian Urban <christian.urban@kcl.ac.uk>
Fri, 04 Nov 2022 12:07:40 +0000
changeset 894 02ef5c3abc51
parent 864 solution/cw2/fib.while@b5b1bc0a603b
child 920 7af2eea19646
permissions -rw-r--r--
updatedHG: added solutions/cw5/fun_tokens.sc

write "Fib";
read n;  
minus1 := 1;
minus2 := 0;
while n > 0 do {
       temp := minus2;
       minus2 := minus1 + minus2;
       minus1 := temp;
       n := n - 1
};
write "Result: ";
write minus2