Created
March 2, 2021 11:46
-
-
Save bogoreh/f42489beba3791b4bb561389ba66dde5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var factorial = function(n) { | |
| var result = 1; | |
| for (var i = 1; i <= n; i++){ | |
| result = result * i; | |
| } | |
| return result; | |
| }; | |
| println("The value of 5! should be " + 5*4*3*2*1); | |
| println("The value of 5! is " + factorial(5)); | |
| println("The value of 0! should be 1"); | |
| println("The value of 0! is " + factorial(0)); | |
| Program.assertEqual(factorial(5), 120); | |
| Program.assertEqual(factorial(0), 1); | |
| Program.assertEqual(factorial(2), 2); | |
| Program.assertEqual(factorial(4), 24); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment