This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule ProjectEuler.Problem4a do | |
@moduledoc """ | |
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. | |
Find the largest palindrome made from the product of two 3-digit numbers. | |
iex> ProjectEuler.Problem4a.solve | |
906609 | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Fib do | |
# Naive implementation | |
def fib(0), do: 0 | |
def fib(1), do: 1 | |
def fib(n) | |
when is_integer(n) and n > 1, | |
do: fib(n-1) + fib(n-2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule RomanNumeral do | |
@mapping [ | |
{1000, "M"}, | |
{900, "CM"}, | |
{500, "D"}, | |
{400, "CD"}, | |
{100, "C"}, | |
{90, "XC"}, | |
{50, "L"}, | |
{40, "XL"}, |