Skip to content

Instantly share code, notes, and snippets.

@mazeltov7
Created May 30, 2013 06:02
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 mazeltov7/5675961 to your computer and use it in GitHub Desktop.
Save mazeltov7/5675961 to your computer and use it in GitHub Desktop.
閏年(ruby)
puts '先頭の年'
start = gets.chomp.to_i
puts '末尾の年'
stop = gets.chomp.to_i
puts 'うるう年一覧'
year = start
while year <= stop
if (year % 400 == 0) ||
(year % 100 != 0 && year % 4 == 0)
puts year
end
year +=1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment