Last active
December 16, 2015 11:09
-
-
Save catatsuy/5424992 to your computer and use it in GitHub Desktop.
This file contains 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
APP_PI = 3.14 | |
app_pis = (3..1000).map { |n| n * Math.sin(Math::PI / n) } | |
ans = 0 | |
app_pis.each_with_index do |item, n| | |
if (item - APP_PI).abs < (app_pis[ans] - APP_PI).abs | |
ans = n | |
end | |
end | |
puts ans + 3, app_pis[ans] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment