Created
April 6, 2014 13:06
-
-
Save willmcneilly/10005732 to your computer and use it in GitHub Desktop.
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
</body> | |
</html> |
This file contains 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
// A factorial is the product of an integer and all the intergers preceding it. This is an example of linear recursion and iteration | |
// Version with conditional statement rather than a block | |
function factorial(n) { | |
return n === 1 ? 1 : n * factorial(n-1); | |
} | |
console.log(factorial(4)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment