From: Harry Kakueki Date: 2011-09-04T17:18:14+09:00 Subject: Re: Beginner needing help - Writing right-angle triangle program On Sun, Sep 4, 2011 at 5:10 PM, Kane Williams wrote: > Thanks guys! You've both been helpful! Now how would I make it so that > it would return a float? Perhaps up to two decimal places? Here's my > code so far : http://pastie.org/2479748 > > I tried making the range into a float, but then I'm not sure how that > would work, at what decimal point range it would end up at, it gave me > an error anyways. > Check my equations carefully to be sure they are correct. But, it seems to work... Anyway, it's an idea. per = 24 # 2_400_000 (1..per-2).each do |a| c = (a.to_f**2+(per-a)**2)/(2*(per-a)) b = per-a-c p [a,b.to_i,c.to_i] if a>=1 && b>=1 && c>=1 && b == b.to_i # integers only #p [a,b,c] if a>=1 && b>=1 && c>=1 #include floats end Harry