Skip to content

Instantly share code, notes, and snippets.

@masui
Created May 25, 2015 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masui/fea11ba6359267fbf371 to your computer and use it in GitHub Desktop.
Save masui/fea11ba6359267fbf371 to your computer and use it in GitHub Desktop.
a^2 + b^2 == c^2 かつ a+b+c=1000, a < b < c となる a, b, c を求める
(1..1000).each { |i|
(1..1000).each { |j|
k = 1000 - i - j
next if j <= i || k <= j
puts "#{i}, #{j}, #{k}" if i*i + j*j == k*k
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment