Created
August 23, 2018 01:41
-
-
Save Radcliffe/bc212d680c07c7ca584e0a745f1939d5 to your computer and use it in GitHub Desktop.
Naive multiplication with tail recursion
This file contains hidden or 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
-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