isLeapYear function

bool isLeapYear(
  1. int year
)

Check if a year is a leap year per the Gregorian calendar.

A year is a leap year if it is divisible by 4 but not by 100, or divisible by 400.

Implementation

bool isLeapYear(int year) =>
    (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);