Skip to content

Instantly share code, notes, and snippets.

@pppillai
Created May 10, 2020 13:22
Show Gist options
  • Save pppillai/63bce02dc627227de7181e0e68e27ccd to your computer and use it in GitHub Desktop.
Save pppillai/63bce02dc627227de7181e0e68e27ccd to your computer and use it in GitHub Desktop.
-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).
@elbrujohalcon
Copy link

This looks good :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment