Server IP : 92.204.138.22 / Your IP : 3.149.28.134 Web Server : Apache System : Linux ns1009439.ip-92-204-138.us 4.18.0-553.8.1.el8_10.x86_64 #1 SMP Tue Jul 2 07:26:33 EDT 2024 x86_64 User : internationaljou ( 1019) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /proc/self/root/proc/thread-self/root/usr/share/doc/bc/Examples/ |
Upload File : |
/* 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"