login
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.
1
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,4
COMMENTS
Prime(n) stands for the n-th prime.
a(58899)=0, which is the first zero after a(1)=0.
First occurrence of k=1,2,3,...: 1, 2, 5, 4, 9, 18, 23, 39, 105, 202, 236, 321, 730, 820, ..., . - Robert G. Wilson v, Aug 01 2018
EXAMPLE
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.
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}]
(* Alternative: *)
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 *)
PROG
(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
CROSSREFS
Sequence in context: A176059 A262785 A264843 * A379880 A029211 A246925
KEYWORD
nonn,easy
AUTHOR
Lei Zhou, Jun 28 2018
STATUS
approved