As a challenge problem in my number theory course I was asked to find the 2 pairs of triangular numbers $a$ and $b$ smaller than 1000 for which $a+b$ and $a-b$ are also triangular.
For example 15 and 21. I found the pairs, but I was wondering if there is a formula/algorithm for finding them. I started using algebra on the formulas for triangular numbers, but got stuck without a real result. Is there a formula, or how can I derive one?
Answer
Triangle numbers are of the form $(n^2+n)/2$. Look for solutions to $m^2+n^2+m+n=x^2+x$ and $m^2-n^2+m-n=y^2+y$. This is the python code I used:
l=[]
for n in range(1,1000):
l.append(n+n**2)
for a in l:
for b in l:
if a!=b:
if l.count(a+b)!=0:
if l.count(a-b)!=0:
print((a+b)/2,"hey",(a-b)/2,"dee",a/2,"taa",b/2)
Solutions <500000
36.0 hey 6.0 dee 21.0 taa 15.0
276.0 hey 66.0 dee 171.0 taa 105.0
1081.0 hey 325.0 dee 703.0 taa 378.0
1770.0 hey 210.0 dee 990.0 taa 780.0
5886.0 hey 1596.0 dee 3741.0 taa 2145.0
5671.0 hey 2701.0 dee 4186.0 taa 1485.0
12246.0 hey 1326.0 dee 6786.0 taa 5460.0
16653.0 hey 903.0 dee 8778.0 taa 7875.0
60031.0 hey 1225.0 dee 30628.0 taa 29403.0
60726.0 hey 16836.0 dee 38781.0 taa 21945.0
147153.0 hey 6903.0 dee 77028.0 taa 70125.0
293761.0 hey 82621.0 dee 188191.0 taa 105570.0
264628.0 hey 141778.0 dee 203203.0 taa 61425.0
257403.0 hey 181503.0 dee 219453.0 taa 37950.0
477753.0 hey 354903.0 dee 416328.0 taa 61425.0
No comments:
Post a Comment