33 lines
775 B
Text
33 lines
775 B
Text
h,t = getem(200)
|
|
#.sort(h,4,5,1,2,3)
|
|
#.output("There are ",t," Heronian triangles")
|
|
#.output(" a b c area perimeter")
|
|
#.output("----- ----- ----- ------ ---------")
|
|
> i, 1..#.min(10,t)
|
|
print(h,i)
|
|
<
|
|
#.output(#.str("...",">34<"))
|
|
> i, 1..t
|
|
? h[4,i]=210, print(h,i)
|
|
<
|
|
print(h,i)=
|
|
#.output(#.str(h[1,i],">4>")," ",#.str(h[2,i],">4>")," ",#.str(h[3,i],">4>")," ",#.str(h[4,i],">5>")," ",#.str(h[5,i],">8>"))
|
|
.
|
|
getem(n)=
|
|
> a, 1..n
|
|
> b, #.upper((a+1)/2)..a
|
|
> c, a-b+1..b
|
|
x = ((a+b+c)*(a+b-c)*(a-b+c)*(b-a+c))^0.5
|
|
>> x%1 | #.gcd(a,b,c)>1
|
|
t += 1
|
|
h[1,t],h[2,t],h[3,t] = #.sort(a,b,c)
|
|
h[4,t],h[5,t] = heron(a,b,c)
|
|
<
|
|
<
|
|
<
|
|
<= h,t
|
|
.
|
|
heron(a,b,c)=
|
|
s = (a+b+c)/2
|
|
<= (s*(s-a)*(s-b)*(s-c))^0.5, s*2
|
|
.
|