Answers for "factorial of a number"

C++
3

factorial of a given number in c

//Factorial of a given number
#include <stdio.h>

//This function returns factorial of the number passed to it 
long int factorialOf(int number){
    long int factorial = 1;
    while(number){
        factorial*=number;
        number-=1;
    }
    return factorial;
}

int main(void) {
	int n;
	printf("Find factorial of n");
	scanf("%d",&n);
	printf("nThe factorial of %d is %ld",n,factorialOf(n));
	return 0;
}
Posted by: Guest on June-15-2020
14

calculate factorial

int factorial(int n) {
	int res = 1, i; 
    for (i = 2; i <= n; i++) 
        res *= i; 
    return res; 
}
Posted by: Guest on May-02-2020
0

Factorialize a Number

function factorialize(num) {
  for (var product = 1; num > 0; num--) {
    product *= num;
  }
  return product;
}

factorialize(5);
Posted by: Guest on July-31-2021
2

factorial

unsigned long long factorial(unsigned long long num){

    if(num<=0)
        return 1;

    return num * factorial(num-1);
}
Posted by: Guest on December-28-2020

Code answers related to "factorial of a number"

Browse Popular Code Answers by Language