Task

Determine whether a given year is a leap year in the Gregorian calendar.



See also

 Leap year (wiki)


bundle Default {
  class LeapYear {
    function : Main(args : String[]) ~ Nil {
      test_case := [1900, 1994, 1996, 1997, 2000];
      each(i : test_case) {
        test_case[i]->Print();
        if(IsLeapYear(test_case[i])) {
          " is a leap year."->PrintLine();
        }
        else {
          " is not a leap year."->PrintLine();
        };
      };
    }
 
    function : native : IsLeapYear(year : Int) ~ Bool {
      if(year % 4 = 0 & year % 100 <> 0) {
        return true;
      }
      else if(year % 400 = 0) {
        return true;
      };
 
      return false;
    }
  }
}