Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jose committed Oct 13, 2018
1 parent c5bcbc3 commit a294783
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions math/factorial/js/Factorial.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function factorial (n) {
if (n == 0 || n == 1)
return 1;
if (f[n] > 0)
return f[n];
return f[n] = factorial(n-1) * n;
}

//tests
factorial(5)
factorial(3)
factorial(5)
factorial(8)
factorial(10)

0 comments on commit a294783

Please sign in to comment.