Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #14 Feb 23 2024 08:23:19
%S 1,1,1,1,1,2,1,3,2,4,3,3,3,5,4,6,5,6,5,7,6,8,6,8,8,8,9,9,10,10,9,11,
%T 10,12,12,13,11,12,13,13,15,14,14,15,14,16,14,17,17,16,17,17,18,18,19,
%U 18,19,19,21,21,19,21,20,22,24,23,22,22,23,24,25,25,24,25,24,27,26,28,27
%N Number of ways of writing n=k1+k2 with k1 and k2 in A167707.
%e a(31)=9 because 31 = 0 + 31 = 3 + 28 = 5 + 26 = 7 + 24 = 9 + 22 = 10 + 21 = 11 + 20 = 14 + 17 = 15 + 16.
%p isA001097 := proc(n) isprime(n) and (isprime(n+2) or isprime(n-2)) ; end proc:
%p isA164276 := proc(n) not isprime(n) and ( not isprime(n+1) or not isprime(n-1) ) ; end proc: isA167707 := proc(n) isA001097(n) or isA164276(n) ; end proc:
%p A167707 := proc(n) option remember; if n = 1 then 0; else for a from procname(n-1)+1 do if isA167707(a) then return a; end if; end do; end if; end proc:
%p A171618 := proc(n) a := 0 ; for i from 1 do p := A167707(i) ; q := n-p ; if q < p then return a ; end if; if isA167707(q) then a := a+1 ; end if; if q <= p then return a ; end if; end do: end proc:
%p seq(A171618(n),n=1..120) ; # _R. J. Mathar_, May 22 2010
%t isA001097[n_] := PrimeQ[n] && (PrimeQ[n+2] || PrimeQ[n-2]);
%t isA164276[n_] := !PrimeQ[n] && (!PrimeQ[n+1] ||!PrimeQ[n-1]);
%t isA167707[n_] := isA001097[n] || isA164276[n];
%t A167707[n_] := A167707[n] = If[n == 1, 0, For[a = A167707[n-1]+1, True, a++, If[isA167707[a], Return@a]]];
%t A171618[n_] := Module[{a}, a = 0; For[i = 1, True, i++, p = A167707[i]; q = n-p; If[q < p, Return@a]; If[isA167707[q], a++]; If[q <= p, Return@a]]];
%t Table[A171618[n], {n, 1, 120}] (* _Jean-François Alcover_, Feb 23 2024, after _R. J. Mathar_ *)
%Y Cf. A062602, A062610, A167707.
%K nonn
%O 1,6
%A _Juri-Stepan Gerasimov_, Dec 13 2009
%E a(29) and a(34) corrected and sequence extended by _R. J. Mathar_, May 22 2010