Home » » Calculate factorial of a Number without Recursion

Calculate factorial of a Number without Recursion

This is a program for calculating factorial of a given number without any loop or using recursion. Lets look at the code below.




//  Simple Program Factorial Calculation


#include<conio.h>
#include<stdio.h>


int fact(int n)
{
if(n==1||n==0)
return 1;
else
return(fact(n-1)*n);
}

void main()
{
int n,t;
scanf("%d",&n);
printf("%d",fact(n));
getch();
}








Share this article :

0 comments:

Post a Comment

 
My Other Websites : Ad Networks | Games Copyright © 2014. Study Depth - All Rights Reserved