view 5-Erlang/tail_recurse.erl @ 76:5860845f5dac

Create module with synchronous translation and notes on how to run
author IBBoard <dev@ibboard.co.uk>
date Sat, 03 Feb 2018 20:25:47 +0000
parents 32f018861e36
children
line wrap: on
line source

-module(tail_recurse).
-export([factorial/1]).
-export([fibonacci/1]).

factorial(0) -> 1;
factorial(N) -> N * factorial(N-1).
% tail_recurse:factorial(2000). is fast to complete, but gives LONG output! Implies integers are huge

fibonacci(0) -> 1;
fibonacci(1) -> 1;
fibonacci(N) -> fibonacci(N-1) + fibonacci(N-2).