Skip to content

Instantly share code, notes, and snippets.

@iain17
Created April 5, 2017 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iain17/03594558059da5f361bef4f837827177 to your computer and use it in GitHub Desktop.
Save iain17/03594558059da5f361bef4f837827177 to your computer and use it in GitHub Desktop.
Write a function that uses recursion to count to ten.
-module(count).
-export([to_ten/0]).
%Assignment: Write a function that uses recursion to count to ten.
%Entrypoint
to_ten() -> count(0).
% Base case
count(10) -> 10;
%keep on adding 1 untill you reach the above function
count(Value) -> count(Value + 1).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment