Skip to content

Instantly share code, notes, and snippets.

@Radcliffe
Created August 23, 2018 01:41
Show Gist options
  • Save Radcliffe/bc212d680c07c7ca584e0a745f1939d5 to your computer and use it in GitHub Desktop.
Save Radcliffe/bc212d680c07c7ca584e0a745f1939d5 to your computer and use it in GitHub Desktop.
Naive multiplication with tail recursion
-module(multiply).
-export([mul/2]).
mul(A, B) -> mul(A, B, 0).
mul(_, 0, C) -> C;
mul(A, B, C) -> mul(A, B-1, A+C).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment