
Triangle hunting
Triangles with integer sides a,b,c (a =< b =< c) all have perimeter p.
As example, if p = 13, there are 5 triangles:
a,b,c:
1,6,6
2,5,6
3,4,6
3,5,5
4,4,5
I believe this "program coding" gets them all the quickest way:
GET p
IF p is even THEN sa = 2 ELSE sa = 1 (sa means start a)
LOOP a FROM sa TO INT(p/3)
sb = INT[(p  2a) / 2] + 1 : IF sb < a THEN sb = a (sb means start b)
LOOP b FROM sb TO INT[(p  a) / 2]
c = p  a  b
n = n + 1 (count them!)
PRINT a,b,c (if one wishes!)
ENDLOOPS
PRINT n
Can someone confirm that this gets 'em all? Thank you.