write a program to find factorial of a number
Anonymous:
c++ program,or java progam or wht??
Answers
Answered by
8
public class factorial
{
public static void main(int n)
{
int a=n, f=1;
while(a>0)
{
f=f*a;
a--;
}
System. out. println("factorial of a number"+f) ;
}
}
{
public static void main(int n)
{
int a=n, f=1;
while(a>0)
{
f=f*a;
a--;
}
System. out. println("factorial of a number"+f) ;
}
}
Answered by
0
Explanation:
To understand this example, you should have the knowledge of the following C programming topics:
C Data Types
C Programming Operators
C if...else Statement
C for Loop
The factorial of a positive number n is given by:
factorial of n (n!) = 1 * 2 * 3 * 4....n
The factorial of a negative number doesn't exist. And, the factorial of 0 is 1.
Similar questions