0
factorising a number
is the following code correct for factorising a number https://code.sololearn.com/WHj1v9QPkzz1/?ref=app
5 Respostas
+ 2
Msaligs Yes this is correct and also you can get factorial using recursion like this
function fact(num) {
if(num == 0 || num == 1) {
return 1;
}
return num * fact(num - 1);
}
console.log(fact(5))
+ 1
Yes I think it's correct!
+ 1
This logic is to find the factorial of a number.
Factorial of a number is the product from 1 to the number itself.
For example: Factorial of 5 is
1*2*3*4*5=120.
+ 1
Yes it is but what about negative values ?
How to calculate the factorial for negatives???
https://code.sololearn.com/WuQ38sIic7Ro/?ref=app
0
Yup