login
Triangular numbers t such that the following are three triangular numbers: x, y, x+y, where x and y are distances from t to the two nearest squares.
1

%I #23 Oct 16 2024 21:21:12

%S 1,2080,8038045

%N Triangular numbers t such that the following are three triangular numbers: x, y, x+y, where x and y are distances from t to the two nearest squares.

%C No more terms through 10^34. - _Jon E. Schoenfield_, Feb 09 2014

%e 2080 is in the sequence because the following three are triangular numbers:

%e 2080-2025 = 55,

%e 2116-2080 = 36,

%e 55 + 36 = 91.

%e 2025 = 45^2 and 2116 = 46^2 are the nearest to 2080 squares.

%t ttnQ[n_]:=Module[{s=Sqrt[n],x,y},x=If[IntegerQ[s],n-(s-1)^2,n- Floor[ s]^2];y=If[IntegerQ[s],(s+1)^2-n,Ceiling[s]^2-n];AllTrue[ {Sqrt[ 8x+1],Sqrt[8y+1],Sqrt[8(x+y)+1]},OddQ]]; Join[{1},Select[Accumulate[ Range[10000]],ttnQ]] (* The program uses the AllTrue function from Mathematica version 10 *) (* _Harvey P. Dale_, May 30 2015 *)

%o (Python)

%o import math

%o def isTriangular(a):

%o a+=a

%o sr = int(math.sqrt(a))

%o return (a==sr*(sr+1))

%o for n in range(1, 1000000000):

%o tn = int(n*(n+1)/2) # = x+y = distance between squares

%o if tn&1:

%o k = tn>>1

%o k*= k # square below t

%o a = int(math.sqrt(k*2))

%o t = a*(a+1)/2

%o if t <= k:

%o a+=1

%o t+=a

%o ktn = k+tn # square above t

%o while t <= ktn: # check if x and y are triangular:

%o if isTriangular(t-k) and isTriangular(ktn-t):

%o print(int(t))

%o a+=1

%o t+=a

%o if (n&0xfffff)==0: print('.', end='')

%Y Cf. A000217, A000290, A234143.

%K nonn,bref,hard,more

%O 1,2

%A _Alex Ratushnyak_, Dec 19 2013