write a program to input a number n and print its factorial the factorial of a number is the product of all natural number from 1 to that number
Answers
Answered by
1
Answer:
get a chance to look at the house and I will be there at the same time I don't have a car
Explanation:
yuh I have a few questions 66 Yup
Answered by
4
Answer:
class fact
{
public static void main(String args[ ])
{
Scanner in = new Scanner(System.in);
System.out.println("Enter number");
int n = in.nextInt( );
int f = 1;
for(int i =1;i<=n; i++)
{
f = f*i;
}
System.out.println("factorial ="+ f);
}
}
Explanation:
Reading integer number 'n' using Scanner class.After that in a for loop computing the product of 1 to n.The last answer will be the factorial
Similar questions