OFFSET
0,9
LINKS
EXAMPLE
a(16) = 4 because we have [13, 3], [11, 5], [5, 11] and [3, 13].
MAPLE
s:= proc(n) option remember; `if`(n<1, 0, ithprime(n+1)+s(n-1)) end:
b:= proc(n, i, t) option remember; `if`(s(i)<n, 0, `if`(n=0, t!, (p
->`if`(p>n, 0, b(n-p, i-1, t+1)))(ithprime(i+1))+b(n, i-1, t)))
end:
a:= n-> b(n, numtheory[pi](n), 0):
seq(a(n), n=0..72); # Alois P. Heinz, Feb 03 2020
MATHEMATICA
s[n_] := s[n] = If[n < 1, 0, Prime[n + 1] + s[n - 1]];
b[n_, i_, t_] := b[n, i, t] = If[s[i] < n, 0, If[n == 0, t!, If[# > n, 0, b[n - #, i - 1, t + 1]]&[Prime[i + 1]] + b[n, i - 1, t]]];
a[n_] := b[n, PrimePi[n], 0];
a /@ Range[0, 72] (* Jean-François Alcover, Nov 09 2020, after Alois P. Heinz *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Ilya Gutkovskiy, Feb 03 2020
STATUS
approved