[go: up one dir, main page]

login
A229909
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
1, 2080, 8038045
OFFSET
1,2
COMMENTS
No more terms through 10^34. - Jon E. Schoenfield, Feb 09 2014
EXAMPLE
2080 is in the sequence because the following three are triangular numbers:
2080-2025 = 55,
2116-2080 = 36,
55 + 36 = 91.
2025 = 45^2 and 2116 = 46^2 are the nearest to 2080 squares.
MATHEMATICA
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 *)
PROG
(Python)
import math
def isTriangular(a):
a+=a
sr = int(math.sqrt(a))
return (a==sr*(sr+1))
for n in range(1, 1000000000):
tn = int(n*(n+1)/2) # = x+y = distance between squares
if tn&1:
k = tn>>1
k*= k # square below t
a = int(math.sqrt(k*2))
t = a*(a+1)/2
if t <= k:
a+=1
t+=a
ktn = k+tn # square above t
while t <= ktn: # check if x and y are triangular:
if isTriangular(t-k) and isTriangular(ktn-t):
print(int(t))
a+=1
t+=a
if (n&0xfffff)==0: print('.', end='')
CROSSREFS
KEYWORD
nonn,bref,hard,more
AUTHOR
Alex Ratushnyak, Dec 19 2013
STATUS
approved