Skip to main content
2 of 2
Saved 2 bytes by changing negation
Alex A.
  • 24.7k
  • 5
  • 38
  • 119

Julia, 30 28 bytes

y->(y%4<1&&y%100>0)||y%400<1

This creates an unnamed function that accepts an integer argument and returns a boolean value. To call it, give it a name, e.g. f=y->....

Ungolfed:

function f(y)
    (y % 4 == 0 && y % 100 != 0) || y % 400 == 0
end

Example:

julia> for y in [1936, 1805, 1900, 2272, 2400] println(f(y)) end
true
false
false
true
true
true
Alex A.
  • 24.7k
  • 5
  • 38
  • 119