0 Replies - 1217 Views - Last Post: 12 November 2009 - 10:16 AM

#1 EdwinNameless   User is offline

  • D.I.C Addict
  • member icon

Reputation: 128
  • View blog
  • Posts: 723
  • Joined: 15-October 09

Leap year

Posted 12 November 2009 - 10:16 AM

Description: This function return "true" if the year passed as a parameter is leap, false otherwise.
def leap? year
  (year%4 == 0) and !(year%100 == 0 and year%400 != 0)
end

puts leap? 1978 # false
puts leap? 1988 # true
puts leap? 1900 # false
puts leap? 2000 # true

Is This A Good Question/Topic? 0
  • +

Page 1 of 1