defmodule Test do alias Caustic.Format import Caustic.Utils import Enum @moduledoc false def start do m = 14 elems = 0..(m - 1) |> filter(&(gcd(m, &1) == 1)) totient = count elems table = elems |> map(fn a -> 2..totient |> map(&pow_mod(a, &1, m)) end) col_labels = 2..totient |> map(& "a^#{&1}") IO.puts("m = #{m}") IO.puts("φ(m) = #{totient}") Format.print_table(table, elems, col_labels) IO.puts("") table2 = elems |> map(fn a -> elems |> map(& mod(a * &1, m)) end) Format.print_table(table2, elems, elems) end def mp1 do p = mersenne_prime 29 p - p end def mp2 do e = 132049 p = pow(2, e) - 1 p - p end end