mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-15 01:40:49 +08:00
Merge pull request #1304 from Vikrant-Khedkar/master
Added scanner in the factorial program to make finding factorial easy
This commit is contained in:
@ -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
|
||||||
|
Reference in New Issue
Block a user