123456789101112131415161718192021 |
- /*
- Simple prime number generator
- */
- count = 1;
- n = 1;
- limit = 100;
- while (n < limit) {
- k=3;
- p=1;
- n=n+2;
- while ((k*k<=n) && (p)) {
- p=n/k*k!=n;
- k=k+2;
- }
- if (p) {
- print(n, " is prime\n");
- count = count + 1;
- }
- }
- print("Total primes found: ", count, "\n");
|