how to write a function to find a unique triangle?

Lenght of triangle is L,which is an integer ,also the 3 sides are integer.
for Pythagorean theorem , for example,
L=12 can be composed by 3,4,5 or
L=30 from 5,12,13...
but when L=120,sides can be 30,40,50 or 20,48,52, this kind of triangle might not be considered.It can output(0,0,0).
How to write a function, which has as input a length L, and outputs triple(a,b,c) being the only triangle,where the sides( a b c ) all have integer L :otherwise it outputs(0,0,0).
Thanks a lot.

Answers (1)

Gosh. Do they give the identically same homework assignment to every kid in the entire world?
unique(sort(pythagSum(1234567890),2),'rows')
ans =
63080361 584045440 587442089
63627480 583741485 587198925
123456789 548696840 562414261
149857215 532003644 552707031
180721521 511427440 542418929
205761315 493827156 534979419
258784215 453576204 522207471
I'll bet if you bother to look on this site, you will find the code that produced that result, and the idea on which it was based. Of course, if you submit my solution to this problem to your teacher, I'll expect a citation of my work.

Tags

Asked:

on 1 May 2015

Edited:

on 1 May 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!