░▒▓████████████████████████████████▓▒░ ░▒▓█ ▓▒░ ░▒▓█ ~ S W A M P ~ ▓▒░ ░▒▓█ ▓▒░ ░▒▓████████████████████████████████▓▒░
pplmvsvm
LOCATION:
/usr/share/doc/bc/examples
☗ ROOT
↻ REFRESH
✎ CARVE FLESH
EDITING: primes.b
/* An example that finds all primes between 2 and limit. */ define primes (limit) { auto num, p, root, i prime[1] = 2; prime[2] = 3; num = 2; if (limit >= 2) print "prime 1 = 2\n" if (limit >= 3) print "prime 2 = 3\n"; scale = 0; for ( p=5; p <= limit; p += 2) { root = sqrt(p); isprime = 1; for ( i = 1; i < num && prime[i] <= root; i++ ) { if ( p % prime[i] == 0 ) { isprime = 0; break; } } if (isprime) { num += 1; prime [num] = p; print "prime ", num, " = ", p, "\n" } } } print "\ntyping 'primes (10)' will print all primes less than 10.\n"
CANCEL
Name
Type
Size
Modified
Actions
↩ ..
DIR
—
—
📄 ckbook.b
B
330 B
2000-07-07 23:34
EDIT
📄 pi.b
B
1.2 KB
2000-07-07 23:34
EDIT
📄 primes.b
B
633 B
2000-07-07 23:34
EDIT
📄 twins.b
B
710 B
2000-07-07 23:34
EDIT