2 /* An example that finds all primes between 2 and limit. */
4 define primes (limit) {
10 if (limit >= 2) print "prime 1 = 2\n"
11 if (limit >= 3) print "prime 2 = 3\n";
14 for ( p=5; p <= limit; p += 2) {
17 for ( i = 1; i < num && prime[i] <= root; i++ ) {
18 if ( p % prime[i] == 0 ) {
26 print "prime ", num, " = ", p, "\n"
32 print "\ntyping 'primes (10)' will print all primes less than 10.\n"