login

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”).

A224362
Number of partitions of n into a prime and a triangular number.
1
0, 0, 1, 2, 1, 2, 2, 1, 3, 1, 1, 2, 2, 3, 2, 1, 1, 4, 2, 2, 3, 1, 2, 4, 2, 1, 3, 1, 2, 3, 2, 2, 4, 2, 3, 2, 0, 2, 4, 3, 2, 4, 1, 3, 4, 1, 2, 6, 2, 2, 3, 2, 3, 4, 1, 1, 3, 3, 4, 4, 2, 1, 6, 1, 3, 3, 1, 3, 6, 3, 1, 4, 2, 4, 6, 1, 3, 4, 1, 4, 3, 3, 4, 5, 2, 3, 4
OFFSET
0,4
COMMENTS
Indices of zeros: 0 followed by A076768.
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, 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(1<<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(k, end=', ')
CROSSREFS
KEYWORD
nonn
AUTHOR
Alex Ratushnyak, Apr 04 2013
STATUS
approved