Factorial number
In mathematics, the factorial of a positive integer n, denoted by n!, is the product of all positive integers less than or equal to n: n!=n×(n-1)×(n-2)×(n-3)×⋯×3×2×1. For example, 5!=5×4×3×2×1=120, where The value of 0! is 1.
QUESTION:- print the factorial of user input
#include <stdio.h>
#include <conio.h>
int main()
{
int no, fact = 1;
printf("enter a value of a: ");
scanf("%d", &no);
for (int i = 1; i <= no; i++)
{
fact = fact * i;
printf("%d! = %d \n", no, fact);
}
printf("the factorial of %d is %d ", no, fact);
getch();
}
OUTPUT
enter a value of a: 4
4! = 1
4! = 2
4! = 6
4! = 24
the factorial of 4 is 24
0 Comments