mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-11-13 06:23:00 +08:00
Merge a906b7ed69
into ca3d16dcce
This commit is contained in:
commit
eb04541d3f
@ -11,3 +11,16 @@ export default function factorial(number) {
|
|||||||
|
|
||||||
return result;
|
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