Skip to content

Instantly share code, notes, and snippets.

@hyuki0000
Created July 22, 2016 00:47
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 hyuki0000/adcc535e5faa17af8e9f5995ac1f34e8 to your computer and use it in GitHub Desktop.
Save hyuki0000/adcc535e5faa17af8e9f5995ac1f34e8 to your computer and use it in GitHub Desktop.
一年で、月と日の比が円周率に近いのはいつか?
#!/usr/bin/ruby
(1..12).each do |month|
(1..31).each do |day|
r = (month.to_f / day).to_s
s = (day.to_f / month).to_s
puts "#{month}月#{day}日 #{month}/#{day} = #{r}" if r.match(/^3\.1/)
puts "#{month}月#{day}日 #{day}/#{month} = #{s}" if s.match(/^3\.1/)
end
end
# vim: set filetype=ruby:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment