OFFSET
0,4
COMMENTS
Indices of zeros: 0 followed by A076768.
LINKS
T. D. Noe, Table of n, a(n) for n = 0..10000
FORMULA
G.f.: (Sum_{i>=0} x^(i*(i+1)/2))*(Sum_{j>=1} x^prime(j)). - Ilya Gutkovskiy, Feb 07 2017
MATHEMATICA
nn = 13; tri = Table[n*(n + 1)/2, {n, 0, nn}]; pr = Prime[Range[PrimePi[tri[[-1]]]]]; Table[Length[Intersection[pr, n - tri]], {n, 0, tri[[-1]]}] (* T. D. Noe, Apr 05 2013 *)
PROG
(Python)
import math
primes = [2]*2
primes[1] = 3
def isprime(k):
for p in primes:
if k%p==0: return 0
primes.append(k)
return 1
def rootTriangular(a):
sr = 2**(int(math.log(a, 2))+2)
while a < sr*(sr+1)/2:
sr>>=1
b = sr>>1
while b:
s = sr+b
if a >= s*(s+1)/2:
sr = s
b>>=1
return sr
for i in range(1L<<10):
k = 0
for p in primes:
if i <= p: continue
r = rootTriangular(i - p)
if r*(r+1)/2 == i-p: k+=1
if i>1:
if i<=3: k += 1
else: k += isprime(i)
print str(k)+', ',
CROSSREFS
KEYWORD
nonn
AUTHOR
Alex Ratushnyak, Apr 04 2013
STATUS
approved