Skip to content

Instantly share code, notes, and snippets.

@masui masui/slow.rb
Created May 26, 2015

What would you like to do?
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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.