Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #20 Dec 12 2024 23:33:07
%S 0,1,0,1,2,3,4,3,3,3,1,3,4,4,5,4,5,3,4,4,5,4,4,7,8,6,5,7,4,5,9,5,6,5,
%T 9,7,4,5,8,5,8,6,7,5,9,6,5,7,6,4,3,9,6,5,12,8,5,6,7,7,6,9,8,7,13,4,8,
%U 4,6,6,7,4,7,11,5,8,8,9,6,7,7,6,12,4,10,11,11,7,8,11
%N a(n) is the number of ways of writing prime(n) as k-q with q a prime and k a primorial.
%C Except at n=2, the largest k which must be considered is the product of the first n-1 primes, since if k includes p=prime(n) itself then q = k-p is divisible by p and so not prime.
%e For n=4, p = prime(4) = 7 can be written as p = 30 - 23, where 30 is a primorial and 23 is prime, but no other primorials satisfy this condition, so a(3) = 1.
%t a[n_] := Count[FoldList[Times, Prime[Range[n - 1]]] - Prime[n], _?(# > 0 && PrimeQ[#] &)]; a[2] = 1; Array[a, 100] (* _Amiram Eldar_, Nov 14 2024 *)
%o (PARI) a(n)={my(p=prime(n), s=0, t=1); forprime(q=2, p, t*=q; if(t>p && isprime(t-p), s++)); s} \\ _Andrew Howroyd_, Nov 14 2024
%Y Cf. A002110, A175933.
%K nonn,new
%O 1,5
%A _Daniel D Gibson_, Nov 10 2024