solutions/cw2/fib.while
changeset 894 02ef5c3abc51
parent 864 b5b1bc0a603b
child 920 7af2eea19646
equal deleted inserted replaced
893:54a483a33763 894:02ef5c3abc51
       
     1 write "Fib";
       
     2 read n;  
       
     3 minus1 := 1;
       
     4 minus2 := 0;
       
     5 while n > 0 do {
       
     6        temp := minus2;
       
     7        minus2 := minus1 + minus2;
       
     8        minus1 := temp;
       
     9        n := n - 1
       
    10 };
       
    11 write "Result: ";
       
    12 write minus2 
       
    13