Heronian triangles: Difference between revisions

Content deleted Content added
m →‎{{header|REXX}}: aligned statement and a comment.
→‎{{header|REXX}}: added check for: if side A is even, sides B and C must be odd. This decreased execution time by around 1/3.
Line 695: Line 695:
Heron: @.=.; y=' '; minP=9e9; maxP=0; minA=9e9; maxA=0; Ln=length(N)
Heron: @.=.; y=' '; minP=9e9; maxP=0; minA=9e9; maxA=0; Ln=length(N)
#=0; #.=0; #.2=1 #.3=1; #.7=1; #.8=1 /*¬good √.*/
#=0; #.=0; #.2=1 #.3=1; #.7=1; #.8=1 /*¬good √.*/
do a=3 to N /*start at a minimum side length.*/
do a=3 to N; ev=\(a//2) /*start at a minimum side length.*/
do b=a to N; ab=a+b /*AB: is used for summing below.*/
inc=1+ev /*if A is even, B & C must be odd*/
do c=b to N; p=ab+c; s=p/2 /*calculate the Perimeter and S.*/
do b=a+ev to N by inc; ab=a+b /*AB: is used for summing below.*/
do c=b to N by inc; p=ab+c; s=p/2 /*calc Perimeter, S*/
_=s*(s-a)*(s-b)*(s-c); if _<=0 then iterate /*_ isn't positive.*/
_=s*(s-a)*(s-b)*(s-c); if _<=0 then iterate /*_ isn't positive.*/
if pos(.,_)\==0 then iterate /*not an integer. */
if pos(.,_)\==0 then iterate /*not an integer. */