login
Numbers n such that a positive number m <= n exists such that n-m, n+m, and n*m are triangular numbers.
2

%I #18 Jun 08 2021 18:31:25

%S 19,171,271,1428,2178,3781,4053,9303,19459,37980,51238,52669,71316,

%T 97083,127014,147978,188074,411675,733591,1018171,1620010,1701078,

%U 1753416,2159496,2642781,4542678,5244753,7337736,10217611,12251265,16212831,17100132,35839545,43400544

%N Numbers n such that a positive number m <= n exists such that n-m, n+m, and n*m are triangular numbers.

%C Sequence of corresponding m's begins: 9, 105, 135, 525, 2100, 1890, 225, 3417, 14994, 23445, 15192, 26334, 19635, 40467, 1764, 142725, 171054, 382755, 366795, 998865, 8100, ...

%C Conjectures:

%C 1. The sequence is infinite.

%C 2. There is only one m for each n (this is true for n < 2^26).

%e The following three are triangular numbers:

%e 271-135 = 136,

%e 271+135 = 406,

%e 271*135 = 36585.

%e So 271 is in the sequence.

%t pnmQ[n_]:=Length[Select[Table[{n-m,n+m,n m},{m,n}],AllTrue[ Sqrt[ 8#+1],OddQ]&]]>0; Select[Range[20000],pnmQ] (* The program generates the first nine terms of the sequence. To generate more, increase the Range constant, but the program may take a long time to run. *) (* Requires Mathematica version 10 or later *) (* _Harvey P. Dale_, Jun 08 2021 *)

%o (Java)

%o public class A224935 {

%o public static long sr0 = 1;

%o public static boolean[] isTriang = new boolean[5 << 25];

%o public static boolean isTriangular(long a) {

%o long b, s, sr = sr0;

%o while (a < sr*(sr+1)/2) sr>>=1;

%o b = sr>>1;

%o while (b!=0) {

%o s = sr+b;

%o if (a >= s*(s+1)/2) sr = s;

%o b>>=1;

%o }

%o if (a == sr*(sr+1)/2) return true;

%o return false;

%o }

%o public static void main (String[] args) {

%o for (int i=0; i*(i+1) < 5 << 26; ++i) isTriang[i*(i+1)/2] = true;

%o for (long a = 0; a < 5 << 24; ++a) {

%o long s = 1L << 30, tn = 0, count = 0, lastTn = 0;

%o while (a*a < s*(s+1)/2) s>>=1;

%o sr0 = s;

%o for (long i = 1; tn < a; ++i) {

%o long b = a - tn;

%o if (isTriang[(int)(a*2-tn)])

%o if (isTriangular(a*(a-tn))) { ++count; lastTn = tn; }

%o tn += i;

%o }

%o if (count>0) System.out.printf("\n%d %d %d ", a, a-lastTn, count);

%o if ((a & 0x3fff)==0) System.out.printf(".");

%o }

%o }

%o }

%Y Cf. A000217, A224954.

%K nonn

%O 1,1

%A _Alex Ratushnyak_, Apr 20 2013