write a menu driven to find factorial of a number
Answers
Answered by
2
Question:-
- Write a program to find factorial of a number.
Code:-
import java.util.*;
class Factorial
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter a number: ");
int n=sc.nextInt();
long f=1L;
int i=1;
while(i++<=n)
f*=i;
System.out.println("Factorial is: "+f);
}
}
Similar questions
Math,
3 months ago
Math,
3 months ago
English,
3 months ago
Social Sciences,
6 months ago
Geography,
11 months ago