Skip to content

Instantly share code, notes, and snippets.

@willmcneilly
Created April 6, 2014 13:06
Show Gist options
  • Save willmcneilly/10005732 to your computer and use it in GitHub Desktop.
Save willmcneilly/10005732 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
</body>
</html>
// 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