From c842f3ce8c47d9dbbdae15eefdc7f06933fdf6b4 Mon Sep 17 00:00:00 2001 From: "exercism-solutions-syncer[bot]" <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Wed, 1 Apr 2026 19:44:15 +0000 Subject: [PATCH] elixir/leap/1 --- solutions/elixir/leap/1/lib/year.ex | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 solutions/elixir/leap/1/lib/year.ex diff --git a/solutions/elixir/leap/1/lib/year.ex b/solutions/elixir/leap/1/lib/year.ex new file mode 100644 index 0000000..da45aad --- /dev/null +++ b/solutions/elixir/leap/1/lib/year.ex @@ -0,0 +1,20 @@ +defmodule Year do + @doc """ + Returns whether 'year' is a leap year. + + A leap year occurs: + + on every year that is evenly divisible by 4 + except every year that is evenly divisible by 100 + unless the year is also evenly divisible by 400 + """ + @spec leap_year?(non_neg_integer) :: boolean + def leap_year?(year) do + cond do + rem(year, 400) == 0 -> true + rem(year, 100) == 0 -> false + rem(year, 4) == 0 -> true + true -> false + end + end +end