A224928 Numbers of pairs {x, y} such that x <= y and triangular(x) + triangular(y) = 2^n.
1, 1, 1, 0, 2, 0, 1, 0, 3, 0, 2, 0, 4, 0, 1, 0, 8, 0, 2, 0, 4, 0, 4, 0, 8, 0, 2, 0, 24, 0, 2, 0, 8, 0, 8, 0, 8, 0, 2, 0, 32, 0, 4, 0, 16, 0, 4, 0, 32, 0, 4, 0, 32, 0, 4, 0, 4, 0, 8, 0, 16, 0, 2, 0, 32, 0, 6, 0, 48, 0, 16, 0, 16, 0, 8, 0, 384, 0, 4, 0, 16, 0, 16, 0, 16, 0, 8, 0, 768, 0, 2, 0, 8, 0, 4, 0, 32, 0, 32, 0, 256
Offset: 0
Keywords
Examples
2^1 = 1 + 1, the only representation of 2 as a sum of two triangular numbers, so a(1)=1. 2^4 = 16 = 1+15 = 6+10, two representations, so a(4) = 2. 2^8 = 256 = 3+253 = 66+190 = 120+136, so a(8) = 3. 2^12 = 4096 = 1+4095 = 91+4005 = 1540+2556 = 2016+2080, so a(12) = 4.
Links
- Antti Karttunen, Table of n, a(n) for n = 0..329
Programs
-
C
#include
#include typedef unsigned long long U64; U64 isTriangular(U64 a) { // ! Must be a <= (1<<63) U64 s = sqrt(a*2); if (a>=(1ULL<<63)) { if (a==(1ULL<<63)) return 0; printf("Error: a = %llu\n", a), exit(1); } return (s*(s+1)/2 == a); } int main() { U64 c, n, x, tx; for (n = 1; n; n+=n) { for (c = x = tx = 0; tx*2 <= n; ++x, tx+=x) if (isTriangular(n - tx)) ++c;//, printf("(%llu+%llu) ", tx, n-tx); printf("%llu, ", c); } return 0; } -
PARI
A008441(n) = if(!n,n,sumdiv(4*n + 1, d, (d%4==1) - (d%4==3))); A052343(n) = if(!n,1,my(u=A008441(n)); ((u\2)+(u%2))); A224928(n) = A052343(2^n); \\ Antti Karttunen, May 24 2021
Formula
a(n) = A052343(2^n).
Extensions
More terms from Antti Karttunen, May 24 2021
Comments