Tin

Examples · learn/03-functions · 89 of 339

task-2.solution

Divisible by 4, except centuries, except every 400 years.

examples/learn/03-functions/task-2.solution.tintin run examples/learn/03-functions/task-2.solution.tin
// Divisible by 4, except centuries, except every 400 years.
fn isLeap(year: int): bool => year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)

fn main() {
  print("2024: {isLeap(2024)}")
  print("1900: {isLeap(1900)}")
  print("2000: {isLeap(2000)}")
  print("2026: {isLeap(2026)}")
}