wu :: forums (http://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi)
riddles >> medium >> semi perimeter a square
(Message started by: Christine on Mar 30th, 2014, 1:26pm)

Title: semi perimeter a square
Post by Christine on Mar 30th, 2014, 1:26pm
Can you find a triangle whose area, sides are integers and the semi perimeter is a square?

Is there an algorithm to generate them?

Title: Re: semi perimeter a square
Post by pex on Mar 30th, 2014, 5:27pm

on 03/30/14 at 13:26:51, Christine wrote:
Can you find a triangle whose area, sides are integers and the semi perimeter is a square?

Yes. The simplest triangle with integer sides and area that I can think of has sides 3,4,5. Its semiperimeter is 6, so scaling the whole thing up by a factor of 6 works: the 18,24,30 triangle fits the requirements.

Title: Re: semi perimeter a square
Post by Christine on Apr 10th, 2014, 3:18pm

on 03/30/14 at 17:27:03, pex wrote:
Yes. The simplest triangle with integer sides and area that I can think of has sides 3,4,5. Its semiperimeter is 6, so scaling the whole thing up by a factor of 6 works: the 18,24,30 triangle fits the requirements.


Thanks. I'm looking for a primitive Heronian triangle

Title: Re: semi perimeter a square
Post by towr on Apr 10th, 2014, 11:13pm
The smallest primitive with those properties is 8,5,5 (which is just 2 (5,4,3)'s put together)

You can generate a list based on http://en.wikipedia.org/wiki/Heronian_triangle#Exact_formula_for_Heronian_triangles

e.g.
Python
Code:
from fractions import gcd

for m in range(1000):
for n in range(1,m+1):
 for k in range(int(((m**2*n)/(2*m+n))**0.5-1), int((m*n)**0.5)+1):
  if gcd(m,gcd(n,k))==1 and m*n > k**2 >= (m**2*n)/(2*m+n) and m>=n>=1:
   a = n*(m**2+k**2)
   b = m*(n**2+k**2)
   c = (n+m)*(m*n-k**2)
   g = gcd(a,gcd(b,c))
   a /= g
   b /= g
   c /= g
   s = (a+b+c)/2
   if int(s**0.5)**2==s:
    print (m,n,k, a,b,c, (a+b+c)/2)



(697, 657, 104) is the first I've found to also have a square area.



Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board