A316290 a(n) is the number of ways of writing prime(n) as the sum of a prime number and a number that has only prime factors 2 and/or 5.
0, 1, 1, 3, 2, 3, 2, 3, 4, 2, 3, 3, 2, 4, 4, 4, 2, 5, 4, 4, 4, 4, 6, 2, 3, 3, 6, 5, 5, 5, 3, 4, 4, 6, 2, 5, 4, 4, 7, 5, 4, 6, 4, 3, 5, 6, 5, 3, 5, 6, 4, 5, 5, 3, 5, 6, 4, 6, 5, 5, 5, 6, 4, 5, 6, 6, 5, 4, 5, 5, 6, 4, 6, 4, 5, 6, 5, 5, 4, 5, 4, 5, 6, 6, 6, 6, 6
Offset: 1
Examples
For n=2, the 2nd prime is 3, 3-1=2 is prime. This is the only case. So a(2)=1; ... For n=4, the 4th prime is 7, 7-2=5, 7-4=3, and 7-5=2 are prime. So a(4)=3; ... For n=9, the 9th prime is 23, 23-4=19, 23-10=13, 23-16=7, 23-20=3, 4 valid numbers found, so a(9)=4.
Programs
-
Maple
A316290 := proc(n) local pri,a,p,k ; pri := ithprime(n) ; a := 0 ; p := 2; while p < pri do k := pri-p ; if nops(numtheory[factorset](k) minus {2,5}) = 0 then a := a+1 ; end if; p := nextprime(p) ; end do: a ; end proc: seq(A316290(n),n=1..30) ; # R. J. Mathar, Aug 03 2018
-
Mathematica
g = {1}; Table[p = Prime[n]; While[l = Length[g]; g[[l]] < p, pos = l + 1; While[pos--; c2 = g[[pos]]*2; c2 > g[[l]]]; c2 = g[[pos + 1]]*2; pos = l + 1; While[pos--; c5 = g[[pos]]*5; c5 > g[[l]]]; c5 = g[[pos + 1]]*5; c = Min[c2, c5]; AppendTo[g, c]]; ct = 0; i = 0; While[i++; cn = g[[i]]; cn < p, If[PrimeQ[p - cn], ct++]]; ct, {n, 1, 87}] (* Second program: *) Block[{nn = 450, k}, k = Sort@ Flatten@ Table[2^a * 5^b, {a, 0, Log[2, nn]}, {b, 0, Log[5, nn/(2^a)]}]; Table[Count[p - TakeWhile[k, # <= p &], ?PrimeQ], {p, Prime@ Range@ PrimePi@ nn}]] (* _Michael De Vlieger, Jun 29 2018 *) twoFiveableQ[n_] := PowerMod[10, n, n] == 0; a[n_] := Block[{p = Prime@ n}, Length@ Select[p - Select[Range@ p, twoFiveableQ], PrimeQ]]; Array[a, 105] (* Robert G. Wilson v, Aug 01 2018 *)
-
PARI
a(n) = my(p=prime(n)); sum(k=1, p, isprime(p-k) && (k == 2^valuation(k,2)*5^valuation(k, 5))); \\ Michel Marcus, Aug 02 2018
Comments