login
Triangular numbers that are the product of 4 distinct triangular numbers greater than 1.
0

%I #7 Jun 12 2013 13:56:09

%S 25200,97020,145530,499500,673380,749700,839160,1185030,1445850,

%T 1786995,1873080,2031120,2049300,2162160,2821500,3444000,3646350,

%U 4250070,4573800,4915680,4991220,5364450,5512860,6193440,11594520,11763675,12748725,13857480,14340690,15481830

%N Triangular numbers that are the product of 4 distinct triangular numbers greater than 1.

%o (C)

%o #include <stdio.h>

%o #include <math.h>

%o typedef unsigned long long U64;

%o U64 isTriangular(U64 a) { // ! Must be a < (1<<63)

%o U64 s = sqrt(a*2);

%o if (a>=(1ULL<<63)) exit(1);

%o return (s*(s+1) == a*2);

%o }

%o int compare64(const void *p1, const void *p2) {

%o if (*(U64*)p1 == *(U64*)p2) return 0;

%o return (*(U64*)p1 < *(U64*)p2) ? -1 : 1;

%o }

%o #define TOP (1ULL<<19)

%o U64 d[TOP];

%o int main() {

%o U64 n, x, tx, y, ty, z, tz, w, tw, p = 0;

%o for (x = tx = 3; tx <= TOP; tx+=x, ++x) {

%o for (y = ty = 3; ty < tx; ty+=y, ++y) {

%o for (z = tz = 3; tz < ty; tz+=z, ++z) {

%o for (w = tw = 3; tw < tz; tw+=w, ++w) {

%o n = tx*ty*tz;

%o if (n<TOP*180 && (n*=tw)<TOP*180 && isTriangular(n))

%o d[p++] = n;

%o }}}}

%o qsort(d, p, 8, compare64);

%o for (x=n=0; n<p; ++n)

%o if (d[n] > x) x = d[n], printf("%llu, ", x);

%o return 0;

%o }

%Y Cf. A000217, A225440.

%K nonn

%O 1,1

%A _Alex Ratushnyak_, Jun 09 2013