C

Factorial using recursion in C

#include <stdio.h>

 int factorials( int n ){
    if(n == 0 ){
        return 1;
    }else if(n>0){
        return n * factorials(n-1);
    }
}



int main()
{
  
    int num;
    printf("Please Enter a Number\n");
    scanf("%d",&num);
    printf("Factorial of %d is %d", num, factorials(num)); 

    return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

October 2020
M T W T F S S
« Sep   Nov »
 1234
567891011
12131415161718
19202122232425
262728293031  

Site Statistics

  • Users online: 0 
  • Visitors today : 14
  • Page views today : 14
  • Total visitors : 3,982
  • Total page view: 4,457