This commit is contained in:
2024-07-03 01:39:58 -04:00
parent 643a41d53c
commit 2eb14fcd40
10 changed files with 288 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
defmodule Grains do
@doc """
Calculate two to the power of the input minus one.
"""
@spec square(pos_integer()) :: {:ok, pos_integer()} | {:error, String.t()}
def square(number) when number > 64 or number < 1, do: {:error, "The requested square must be between 1 and 64 (inclusive)"}
def square(number), do: {:ok, 2 ** (number - 1)}
@doc """
Adds square of each number from 1 to 64.
"""
@spec total :: {:ok, pos_integer()}
def total, do: {:ok, 2 ** 64 - 1}
end