All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Numbers
Pythagorean Triples #1 (Posted on 2024-01-31) Difficulty: 3 of 5
Find two Pythagorean triples A,B,C and D,E,F such that A+D is a triangular number, B+E is a triangular number, and C+F is a triangular number.

Triangular numbers are numbers of the form N(N+1)/2, such as 1, 3, 6, 10, 15, ... .

See The Solution Submitted by K Sengupta    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 1 of 2
The program builds a table of Pythagorean triples and then looks for pairs to add together to get three triangular numbers:


clearvars,clc

Pyth=double.empty(0,3);
for m=1:500
  for n=1:m-1
    if gcd(m,n)==1
      if mod(m*n,2)==0
        a=m^2-n^2;
        b=2*m*n;
        c=m^2+n^2;
        for k=1:300
          p=k*[a b c];
          if a<300
            Pyth(end+1,:)=p;
          else
            break
          end
        end
      end
    end
  end
end

for a=1:length(Pyth)
  p1=Pyth(a,:);
  for b=p:length(Pyth);
    p2=Pyth(b,:);
    if isTri(p1(1)+p2(1))
      if isTri(p1(2)+p2(2))
        if isTri(p1(3)+p2(3))
          fprintf('%6d %6d %6d\n',p1)
          fprintf('%6d %6d %6d\n',p2)
          fprintf('%6d %6d %6d \n',p1+p2)
          for i=1:3
            fprintf('%6d ', whichTri(p1(i)+p2(i)))
          end
          fprintf('\n')
          disp(' ')
        end
      end
    end
  end
end

function t=isTri(n)
sq=2*n;
sr=round(sqrt(sq));
if sr*(sr+1)/2==n
  t=true;
else
  t=false;
end
end

function w=whichTri(n)
sq=2*n;
sr=round(sqrt(sq));
if sr*(sr+1)/2==n
  w=sr;
else
  w=0;
end
end

The first instance of valid pairs of Pythagorean triples is

39, 52, 65  and  132, 224, 260

Adding corresponding elements gives

 171, 276, 325
 
which are, respectively, the 18th, 23rd and 25th triangular numbers. 



First two lines are the two Pythagorean Triples.
Third line is their sum.
Fourth line identifies which triangular number each is.


    39     52     65
   132    224    260
   171    276    325 
    18     23     25 
 
    45     60     75
   990   5400   5490
  1035   5460   5565 
    45    104    105 
 
    45     60     75
 10395   7200  12645
 10440   7260  12720 
   144    120    159 
 
    66     88    110
   234   1040   1066
   300   1128   1176 
    24     47     48 
 
   168    224    280
   183   1856   1865
   351   2080   2145 
    26     64     65 
 
   183    244    305
   520    576    776
   703    820   1081 
    37     40     46 
 
   189    252    315
  1242   1344   1830
  1431   1596   2145 
    53     56     65 
 
   195    260    325
  7065   4396   8321
  7260   4656   8646 
   120     96    131 
 
   225    300    375
  3780   1296   3996
  4005   1596   4371 
    89     56     93 
 
   330    440    550
  1155   1100   1595
  1485   1540   2145 
    54     55     65 
 
   342    456    570
  1254    720   1446
  1596   1176   2016 
    56     48     63 
 
   426    568    710
   900    560   1060
  1326   1128   1770 
    51     47     59 
 
   630    840   1050
  1323    336   1365
  1953   1176   2415 
    62     48     69 
 
   630    840   1050
   855  24360  24375
  1485  25200  25425 
    54    224    225 
 
   720    960   1200
  1050   3600   3750
  1770   4560   4950 
    59     95     99 
 
   750   1000   1250
  1020    128   1028
  1770   1128   2278 
    59     47     67 
 
   771   1028   1285
  2310   1600   2810
  3081   2628   4095 
    78     72     90 
 
   175    420    455
   420    400    580
   595    820   1035 
    34     40     45 
 
   285    684    741
   891    912   1275
  1176   1596   2016 
    48     56     63 
 
   300    720    780
 25806  20808  33150
 26106  21528  33930 
   228    207    260 
 
   465   1116   1209
 11781 150960 151419
 12246 152076 152628 
   156    551    552 
 
   610   1464   1586
  1805   3192   3667
  2415   4656   5253 
    69     96    102 
 
   620   1488   1612
   605    528    803
  1225   2016   2415 
    49     63     69 
 
   675   1620   1755
  4275   7560   8685
  4950   9180  10440 
    99    135    144 
 
   675   1620   1755
  1881   1540   2431
  2556   3160   4186 
    71     79     91 
 
   715   1716   1859
  3380   3744   5044
  4095   5460   6903 
    90    104    117 
 
Operation terminated by user during pythagoreanTriplesNo1 

>> 

  Posted by Charlie on 2024-01-31 13:57:22
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (9)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information