Saturday, 22 July 2017

Write a program to that read the non negative integers & compute & prints its factorial. (5! = 5*4*3*2*1 = 120)

Write a program to that read the non negative integers & compute & prints its factorial. (5! = 5*4*3*2*1 = 120).

The factorial of a non-negative integer n is written n! (stated “n factorial”)
and is defined as follows:
n! = n×(n-1)×(n-2). . . × 1 (for values of n more than 1)

What is factorial?


The factorial, symbolized via an exclamation mark (!), is a quantity defined for all integer s more than or same to zero.

For an integer n extra than or identical to one, the factorial is the made from all integers much less than or identical to n however more than or equal to one. The factorial fee of 0 is defined as same to one. The factorial values for negative integers aren't defined.

Mathematically, the formulation for the factorial is as follows. If n is an integer extra than or identical to one, then
n ! = n ( n - 1)( n - 2)( n - 3) ... (3)(2)(1)
If p = 0, then p ! = 1 by convention.
The factorial is of hobby to wide variety theorists. It frequently arises in probability calculations, particularly those regarding mixtures and permutations. The factorial also arises every now and then in calculus and physics.

Code:


#include<stdio.h>
#include<conio.h>
void main()
{
 int a,b,n;
 b=1;
 printf("Enter The Number ");
 scanf("%d",&n);
 for (a=1;a<=n;a++)
 b=b*a;
 printf("Factorial Is %d",b);
 getch();
 clrscr();
}

Output:


Try it yourself.
If you have any problem you can tell me on comment box i will help you.
thanks.

Viral Programs

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation.

0 comments:

Post a Comment