Answers for "factorial using recursion in c"

C
4

find factoril in C using recursion

#include<stdio.h>
fact(int i, int k){
    k=k*i;
    i--;
    if(i==0){
        return k;
    }
    else{
        fact(i, k);
    }
}
int main()
{
    int k = 1, i, factorial;
    scanf("%d",&i);
    factorial = fact(i, k);
    printf("%d\n",factorial);
    return 0;
}
Posted by: Guest on January-31-2021
1

factorial using recursion in c

#include <stdio.h>

unsigned long long int factorial(unsigned int i) 
{
if(i <= 1) 
{
  return 1;
}
   return i * factorial(i - 1);
}

int  main() {
   int i = 12;
   printf("Factorial of %d is %d\n", i, factorial(i));
   return 0;
}
Posted by: Guest on July-16-2021
2

factorial using recursion in c

#include <stdio.h>

unsigned long long int factorial(unsigned int i) {

   if(i <= 1) {
      return 1;
   }
   return i * factorial(i - 1);
}

int  main() {
   int i = 12;
   printf("Factorial of %d is %d\n", i, factorial(i));
   return 0;
}
Posted by: Guest on May-28-2020

Code answers related to "factorial using recursion in c"

Code answers related to "C"

Browse Popular Code Answers by Language