annotate lab3/sumpow.p @ 1:b5139af1a420 tip basis

Fixed permissions on compile scripts
author Mike Spivey <mike@cs.ox.ac.uk>
date Fri, 13 Oct 2017 17:27:58 +0100
parents bfdcc3820b32
children
rev   line source
mike@0 1 (* lab3/sumpow.p *)
mike@0 2
mike@0 3 proc sumpow(n, k);
mike@0 4 var m, s;
mike@0 5
mike@0 6 proc pow(p);
mike@0 7 var j, q;
mike@0 8 begin
mike@0 9 j := 0; q := 1;
mike@0 10 while j < k do
mike@0 11 j := j+1; q := q*p
mike@0 12 end;
mike@0 13 return q
mike@0 14 end;
mike@0 15
mike@0 16 begin
mike@0 17 m := 0; s := 0;
mike@0 18 while m < n do
mike@0 19 m := m + 1;
mike@0 20 s := s + pow(m)
mike@0 21 end;
mike@0 22 return s
mike@0 23 end;
mike@0 24
mike@0 25 begin
mike@0 26 print sumpow(5, 4); newline
mike@0 27 end.
mike@0 28
mike@0 29 (*<<
mike@0 30 979
mike@0 31 >>*)