All pastes #572638 Raw Edit

Untitled

public text v1 · immutable
·published 2007-06-17 19:43 UTC
rendered paste body
  sq = []
  i = 1
  while i <= 500
    sq.push i
    i += 1
  end
  catch :done do
    for c in sq
      for b in sq
        if c**2 > b**2 && (c**2 - b**2).square? && Math.sqrt(c**2 - b**2) + b + c == 1000
          a = Math.sqrt(c**2 - b**2)
          puts "Product 'abc' of the only Pythagorean triple where a+b+c = 1000: #{(a*b*c).to_i}"
          throw :done
        end
      end
    end
  end