solution/cw3/primes.while
changeset 894 02ef5c3abc51
parent 893 54a483a33763
child 895 2f5a87ecdc81
equal deleted inserted replaced
893:54a483a33763 894:02ef5c3abc51
     1 // prints out prime numbers from
       
     2 // 2 to 100 (end)
       
     3 
       
     4 end := 100;
       
     5 n := 2;
       
     6 while (n < end) do {
       
     7   f := 2;
       
     8   tmp := 0;
       
     9   while ((f < n / 2 + 1) && (tmp == 0)) do {
       
    10     if ((n / f) * f == n) then  { tmp := 1 } else { skip };
       
    11     f := f + 1
       
    12   };
       
    13   if (tmp == 0) then { write(n); write("\n") } else { skip };
       
    14   n  := n + 1
       
    15 }