Merge pull request #1304 from Vikrant-Khedkar/master

Added scanner in the factorial program to make finding factorial easy
This commit is contained in:
Stepfen Shawn
2020-05-08 13:12:37 +08:00
committed by GitHub

View File

@ -1,10 +1,13 @@
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) { //main method
int n = 5; int n = 1;
System.out.println(n + "! = " + factorial(n)); Scanner sc= new Scanner(System.in);
System.out.println("Enter Number");
n=sc.nextInt();
System.out.println(n + "! = " + factorial(n));
} }
//Factorial = n! = n1 * (n-1) * (n-2)*...1 //Factorial = n! = n1 * (n-1) * (n-2)*...1