| about | help | code help+videos | done | prefs |
This function should return true if the given year is a leap year and false otherwise. Only positive values will be used for years. Most years that are divisible by 4 are leap years, but there are exceptions. Years that are divisible by 100 are not leap years, unless they are also divisible by 400, in which case they are still a leap year! If we had a leap year every 4 years, it would over correct and our calendars would fall out of sync. To correct for this, years divisible by 100 are not counted as leap years (for instance, 1900 was not a leap year). However, this over corrects too much in the other direction! To avoid over correcting, we still count years divisible by 400 as leap years (for instance, 2000 was a leap year!) is_leap_year(1998) → False is_leap_year(2001) → False is_leap_year(2004) → True ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Copyright Nick Parlante 2017 - privacy