Questions and Answers
Problems and Solutions
Monday, December 10, 2012
Codeyear: Review: Factorial
//sample solution
// Write a function to get the factorial of a number.
function factorial(int){
//base case
if(int===1){
return 1;
} else {
return int*factorial(int-1);
}
}
//check
console.log(factorial(3));
No comments:
Post a Comment
‹
›
Home
View web version
No comments:
Post a Comment