- All years divisible by 400 ARE leap years (so, for example, 2000 was indeed a leap year)
- All years divisible by 100 but not by 400 are NOT leap years (so, for example, 1700, 1800, and 1900 were NOT leap years, NOR will 2100 be a leap year)
- All years divisible by 4 but not by 100 ARE leap years (e.g., 2008, 2012, 2016)
- All years not divisible by 4 are NOT leap years (e.g. 2017, 2018, 2019)
See: http://codingdojo.org/kata/LeapYears/
using System;
using System.Linq;
internal class Program
{
public static void Main(string[] args)
{
var years = new[] {1700, 1800, 1900, 2000, 2008, 2012, 2016, 2017, 2018, 2019};
Console.WriteLine($"Leap years: {string.Join(", ", years.Where(IsLeapYear))}");
// Output: Leap years: 2000, 2008, 2012, 2016
}
private static bool IsLeapYear(int year)
{
// TODO: Implement this
return true;
}
}