baseConversionTiming.frink

Download or view baseConversionTiming.frink in plain text format

// Program to calculate the value of the largest known Mersenne prime.


p=floor[13466917]

//p=20_996_011   // Largest known as of Nov. 2003
//p=25_964_951    // Largest known as of Feb. 2005.
// p = 30_402_457    // Largest known as of Dec. 2005.
// p = 32_582_657   // Largest as of September 2006
// p = 37_156_667   // Found in September 2008
//p = 43_112_609   // Also found (slightly earlier! in September 2008)
//p = 57_885_161

start = now[]
m=2^p
end = now[]
println["Time to perform exponent: " + ((end-start) -> "seconds")]

start = now[]
mp = m - 1
end = now[]

println["Time to perform subtraction: " + ((end-start) -> 1. seconds) + "\n"]
println["2^" + p + " - 1 =\n"]


for base = 2 to 36
{
   println["Base $base:"]
   start = now[]
   out1 = newToString[mp, base]   // Get string representation
   end = now[]

   //println[out]

   println["Time to format (w/Frink optimizations): " + ((end-start) -> 1. seconds) + "\n"]


   start = now[]
   out2 = oldToString[mp, base]   // Get string representation
   end = now[]

   if out1 != out2
      println["*************** DISCREPANCY *********************"]

   //println[out]

   println["Time to format (native): " + ((end-start) -> 1. seconds) + "\n"]
}


Download or view baseConversionTiming.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 20217 days, 23 hours, 15 minutes ago.