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
commit 63b2ec9886
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,10 +1,13 @@
package Maths;
import java.util.*; //for importing scanner
//change around 'n' for different factorial results
public class Factorial {
public static void main(String[] args) {
int n = 5;
System.out.println(n + "! = " + factorial(n));
public static void main(String[] args) { //main method
int n = 1;
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