Skip to content

Instantly share code, notes, and snippets.

@masui
Created May 26, 2015 06:43
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/43b71336063eca0713ef to your computer and use it in GitHub Desktop.
Save masui/43b71336063eca0713ef 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.upto(1000) do |c|
1.upto(c-1) do |b|
1.upto(b-1) do |a|
next if a + b + c != 1000
next if a * a + b * b != c * c
puts "#{a}^2 == #{b}^2 + #{c}^2"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment