Skip to content

Instantly share code, notes, and snippets.

@catatsuy
Last active December 16, 2015 11:09
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 catatsuy/5424992 to your computer and use it in GitHub Desktop.
Save catatsuy/5424992 to your computer and use it in GitHub Desktop.
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