mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-11-10 11:09:43 +08:00
Merge a906b7ed69
into ca3d16dcce
This commit is contained in:
commit
eb04541d3f
@ -11,3 +11,16 @@ export default function factorial(number) {
|
||||
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* @param {number} number
|
||||
* @return {number}
|
||||
* Recursive solution
|
||||
*/
|
||||
export default function factorial(number){
|
||||
if (number>=1){
|
||||
return number*factorial(number-1);
|
||||
}
|
||||
else{
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user