Computer Science, asked by jeetagarwal972, 6 months ago

write a menu driven to find factorial of a number​

Answers

Answered by anindyaadhikari13
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