Skip to content

Instantly share code, notes, and snippets.

View trhura's full-sized avatar

Thura Hlaing trhura

View GitHub Profile
-module (calculator).
-export ([exponential/2, multiply/2]).
multiply(_, 0) -> 1;
multiply(Num, 1) -> Num;
multiply(Num, Exp) -> Num + multiply(Num, Exp-1).
exponential(_, 0) -> 1;
exponential(Base, 1) -> Base;
exponential(_, Exp) when(Exp < 0) -> throw("Bad argument");