whats the factorial number code example
Example 1: Factorial Number
const factorialNumber = num => {
let factorials = []
for(let i = 1; i <= num; i++) factorials.push(i)
return factorials.reduce((acc , curr) => acc * curr, 1)
}
const factorialNumber = num => {
let factorial = 1, i = 1
while(i <= num){ factorial *= i; i++ }
return factorial
}
function factorialNumber(num) {
if(num < 1) return 1
else return factorialNumber(num - 1) * num
}
Example 2: write a program to find factorial of a number
#include<stdio.h>
int main()
{
int i,fact=1,number;
printf("Enter a number: ");
scanf("%d",&number);
for(i=1;i<=number;i++){
fact=fact*i;