Extract and divide algorithm implementation in Elixir
(untested)

defmodule ExtractAndDivide do
  def extract_and_divide(x) when x &lt; 10, do: x
  def extract_and_divide(x) do
    head = div x, 10
    tail = rem x, 10
    up_or_down = rem tail, 2
    go_up_or_down(head, tail, up_or_down)
  end
  defp go_up_or_down(head, tail, up_or_down) when up_or_down == 0 do
    extract_and_divide(head * 2 + 1)
  end
  defp go_up_or_down(head, tail, _up_or_down_is_one) do
    extract_and_divide(div(head, tail) + rem(head, tail))
  end
end


The idea with having multiple conditional function clauses is twofold: it reduces nesting (and thus should increase readability), and - quite powerful - it allows to to easily test individual conditional parts. Whether to make the recursive call to extract_and_divide by piping the calculation through the function invocation or directly (like I did purely to show the alternative) is largely a matter of taste. 

(note: skipped/circumvented potential nitpicking around naming and whether up_or_down shouldn't be a boolean; I just wanted to illustrate the pattern of doing logic by using multiple function heads)