-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfactorial.java
More file actions
45 lines (34 loc) · 889 Bytes
/
factorial.java
File metadata and controls
45 lines (34 loc) · 889 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
40
41
42
43
44
45
package src;
// Muhammad Naveed
// Factorial
// https://www.github.com/uxlabspk/JavaCodes/
public class factorial {
private int number;
private long factorial;
// Default src.constructor.
public factorial() {
number = 0;
factorial = 1;
}
// Setter method.
public void setNumber(int number) {
this.number = number;
}
// getter method.
public int getNumber() {
return number;
}
// src.factorial finder method
public void findFactorial() {
for (int i = number; i > 0; i--) {
factorial *= i;
}
System.out.println("The src.factorial of " + getNumber() + " is " + factorial);
}
// main method
public static void main(String[] args) {
var factorial = new factorial();
factorial.setNumber(10);
factorial.findFactorial();
}
}