OFFSET
1,1
PROG
(C)
#include <stdio.h>
#include <math.h>
typedef unsigned long long U64;
U64 isTriangular(U64 a) { // ! Must be a < (1<<63)
U64 s = sqrt(a*2);
if (a>=(1ULL<<63)) exit(1);
return (s*(s+1) == a*2);
}
int compare64(const void *p1, const void *p2) {
if (*(U64*)p1 == *(U64*)p2) return 0;
return (*(U64*)p1 < *(U64*)p2) ? -1 : 1;
}
#define TOP (1ULL<<19)
U64 d[TOP];
int main() {
U64 n, x, tx, y, ty, z, tz, w, tw, p = 0;
for (x = tx = 3; tx <= TOP; tx+=x, ++x) {
for (y = ty = 3; ty < tx; ty+=y, ++y) {
for (z = tz = 3; tz < ty; tz+=z, ++z) {
for (w = tw = 3; tw < tz; tw+=w, ++w) {
n = tx*ty*tz;
if (n<TOP*180 && (n*=tw)<TOP*180 && isTriangular(n))
d[p++] = n;
}}}}
qsort(d, p, 8, compare64);
for (x=n=0; n<p; ++n)
if (d[n] > x) x = d[n], printf("%llu, ", x);
return 0;
}
CROSSREFS
KEYWORD
nonn
AUTHOR
Alex Ratushnyak, Jun 09 2013
STATUS
approved