OFFSET
1,3
COMMENTS
EXAMPLE
Triangular(9) = 45 is in the sequence because both 45-36=9 and 49-45=4 are perfect squares, where 36 and 49 are the two squares nearest to 45.
PROG
(C)
#include <stdio.h>
#include <math.h>
typedef unsigned long long U64;
U64 isSquare(U64 a) {
U64 r = sqrt(a);
return r*r==a;
}
int main() {
for (U64 i=0; i<(1ULL<<32); ++i) {
U64 n = i*(i+1)/2, r = sqrt(n);
if (r*r==n && n) --r;
if (isSquare(n-r*r) && isSquare((r+1)*(r+1)-n))
printf("%llu, ", n);
}
return 0;
}
CROSSREFS
KEYWORD
nonn
AUTHOR
Alex Ratushnyak, Dec 23 2013
STATUS
approved