Factorial!

Problem:-

You have been given a positive integer N. You need to find and print the Factorial of this number. The Factorial of a positive integer N refers to the product of all number in the range from 1 to N. You can read more about the factorial of a number here.
Input Format:
The first and only line of the input contains a single integer N denoting the number whose factorial you need to find.
Output Format
Output a single line denoting the factorial of the number N.
Constraints

1N10

SAMPLE INPUT
 
2
SAMPLE OUTPUT
 
2
Time Limit:1.0 sec(s) for each input file.
Memory Limit:256 MB
Source Limit:1024 KB

Solution:

#include<stdio.h>
void main()
{
int n,f=1,i;
scanf(“%d”,&n);
for(i=1;i<=n;i++)
{
f=f*i;
}
printf(“%d”,f);
}

Leave a Reply

Your email address will not be published.