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.

답변 (1개)

John D'Errico
John D'Errico 2015년 5월 1일
편집: John D'Errico 2015년 5월 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.

카테고리

도움말 센터File Exchange에서 Octave에 대해 자세히 알아보기

태그

질문:

2015년 5월 1일

편집:

2015년 5월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by