Skip to content

Commit 63b2ec9

Browse files
authored
Merge pull request TheAlgorithms#1304 from Vikrant-Khedkar/master
Added scanner in the factorial program to make finding factorial easy
2 parents 3b24502 + f6d6725 commit 63b2ec9

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Maths/Factorial.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package Maths;
2+
import java.util.*; //for importing scanner
23

3-
//change around 'n' for different factorial results
44
public class Factorial {
5-
public static void main(String[] args) {
6-
int n = 5;
7-
System.out.println(n + "! = " + factorial(n));
5+
public static void main(String[] args) { //main method
6+
int n = 1;
7+
Scanner sc= new Scanner(System.in);
8+
System.out.println("Enter Number");
9+
n=sc.nextInt();
10+
System.out.println(n + "! = " + factorial(n));
811
}
912

1013
//Factorial = n! = n1 * (n-1) * (n-2)*...1

0 commit comments

Comments
 (0)