added scanner in factorail program

This commit is contained in:
Vikrant Khedkar 2020-05-07 19:30:58 +05:30
parent 3b245025d3
commit 1c062e2c7a

View File

@ -1,9 +1,12 @@
package Maths; package Maths;
import java.util.*; //for importing scanner
//change around 'n' for different factorial results
public class Factorial { public class Factorial {
public static void main(String[] args) { public static void main(String[] args) {
int n = 5; int n = 1;
Scanner sc= new Scanner(System.in);
System.out.println("Enter Number");
n=sc.nextInt();
System.out.println(n + "! = " + factorial(n)); System.out.println(n + "! = " + factorial(n));
} }