Created
May 25, 2015 10:14
-
-
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 を求める
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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