nextPrimeTest.frink

Download or view nextPrimeTest.frink in plain text format


// Tests the nextPrime[n] function
for a=2^31 - million  to 2^31+million
{
   np = nextPrime[a]
   if (np != oldNextPrime[a])
      println["Error at $a"]
   if (a mod 100000 == 0)
      print["$a "]
}

oldNextPrime[n] :=
{
   if (n mod 2 == 0)
      n = n - 1

   do
   {
      n = n + 2
   } while (! isPrime[n])

   return n
}


Download or view nextPrimeTest.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen was born 20145 days, 7 hours, 13 minutes ago.