Cuban Prime

Author

Eric W. Weisstein
September 4, 2006

This notebook downloaded from http://mathworld.wolfram.com/notebooks/PrimeNumbers/CubanPrime.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/CubanPrime.html.

©2006 Wolfram Research, Inc. except for portions noted otherwise

Code

CubanNumber[n_]:=(n^3)-(((n-1))^3)

Enumeration

(l=(Position[-Subtract@@@Partition[Range[0,1000]^3,2,1],_?PrimeQ]//Flatten))//Timing

#^3-(#-1)^3&/@l

Counts

primes=Select[CubanNumber/@Range[10^6],PrimeQ];//Timing

Table[Count[primes,_?(#≤10^n&)],{n,0,Floor[Log[10,CubanNumber[10^6]]]}]

primes=Select[CubanNumber/@Range[10^7],PrimeQ];//Timing

Table[Count[primes,_?(#≤10^n&)],{n,0,Floor[Log[10,CubanNumber[10^7]]]}]

primes=Select[CubanNumber/@Range[10^8],PrimeQ];//Timing

Table[Count[primes,_?(#≤10^n&)],{n,0,Floor[Log[10,CubanNumber[10^8]]]}]

data=MapIndexed[{#2[[1]],Log[#1]}&,{1,4,11,28,64,173,438,1200,3325,9289,26494,76483,221530,645685}];

Fit[#,{1,x},x]&/@{data,Rest[data]}

FindFit[#,x+a,a,x]&/@{data,Rest[data]}

Table[E^(n-0.8),{n,15}]

Show[
Block[{$DisplayFunction=Identity},{ListPlot[Log[{1,4,11,28,64,173,438,1200,3325,9289,26494,76483,221530,645685}],PlotStyle->Red,PlotJoined->True],
Plot[-0.8116455273052344`+1.003100864554427` x,{x,0,15},PlotStyle->Blue],
Plot[x-0.788389043147034`,{x,0,15},PlotStyle->Green]
}
]]

Boost

Times@@N[((#-If[Mod[#,6]==1,2,0])/(#))&/@Prime[Range[10^4]],20]

Times @@ N[((#1 - If[Mod[#1, 6] == 1, 2, 0])/#1 & ) /@ Prime[Range[10^5]], 20]