We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 3b24502 + f6d6725 commit 63b2ec9Copy full SHA for 63b2ec9
Maths/Factorial.java
@@ -1,10 +1,13 @@
1
package Maths;
2
+import java.util.*; //for importing scanner
3
-//change around 'n' for different factorial results
4
public class Factorial {
5
- public static void main(String[] args) {
6
- int n = 5;
7
- System.out.println(n + "! = " + factorial(n));
+ public static void main(String[] args) { //main method
+ int n = 1;
+ Scanner sc= new Scanner(System.in);
8
+ System.out.println("Enter Number");
9
+ n=sc.nextInt();
10
+ System.out.println(n + "! = " + factorial(n));
11
}
12
13
//Factorial = n! = n1 * (n-1) * (n-2)*...1
0 commit comments