-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfacto.java
More file actions
39 lines (30 loc) · 814 Bytes
/
facto.java
File metadata and controls
39 lines (30 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package src;
import java.util.Scanner;
public class facto {
private int number;
private int factorial;
public facto() {
number = 0;
factorial = 1;
}
public void getNumber() {
System.out.print("Enter the number : ");
Scanner s = new Scanner(System.in);
number = s.nextInt();
s.close();
calFactorial();
}
public void calFactorial() {
for (int i = number; i > 0; i--) {
factorial *= i;
}
}
public int getFactorial() {
return factorial;
}
public static void main(String[] args) {
facto f = new facto();
f.getNumber();
System.out.println("The src.factorial of " + f.number + " is : " + f.getFactorial());
}
}