Created
May 10, 2020 13:22
-
-
Save pppillai/63bce02dc627227de7181e0e68e27ccd to your computer and use it in GitHub Desktop.
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
-module(four_arg_fib). | |
-export([fib/1, test_fib/0]). | |
%four argument fib function | |
fib(N) -> | |
fib(0, 0, 1, N). | |
fib(From, Current, _Next, From) -> | |
Current; | |
fib(From, Current, Next, To) -> | |
fib(From+1, Next, Current + Next, To). | |
%test four argument fib function | |
test_fib() -> | |
(fib(0) == 0) andalso (fib(1) == 1) andalso (fib(4) == 3). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This looks good :)