OFFSET
1,6
EXAMPLE
a(31)=9 because 31 = 0 + 31 = 3 + 28 = 5 + 26 = 7 + 24 = 9 + 22 = 10 + 21 = 11 + 20 = 14 + 17 = 15 + 16.
MAPLE
isA001097 := proc(n) isprime(n) and (isprime(n+2) or isprime(n-2)) ; end proc:
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:
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:
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:
seq(A171618(n), n=1..120) ; # R. J. Mathar, May 22 2010
MATHEMATICA
isA001097[n_] := PrimeQ[n] && (PrimeQ[n+2] || PrimeQ[n-2]);
isA164276[n_] := !PrimeQ[n] && (!PrimeQ[n+1] ||!PrimeQ[n-1]);
isA167707[n_] := isA001097[n] || isA164276[n];
A167707[n_] := A167707[n] = If[n == 1, 0, For[a = A167707[n-1]+1, True, a++, If[isA167707[a], Return@a]]];
CROSSREFS
KEYWORD
nonn
AUTHOR
Juri-Stepan Gerasimov, Dec 13 2009
EXTENSIONS
a(29) and a(34) corrected and sequence extended by R. J. Mathar, May 22 2010
STATUS
approved