-
Notifications
You must be signed in to change notification settings - Fork 1
/
Task.java
46 lines (37 loc) · 1.03 KB
/
Task.java
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
46
package com.yurii.salimov.lesson06.task07;
import java.math.BigInteger;
/**
* @author Yuriy Salimov ([email protected])
* @version 1.0
*/
public final class Task implements Runnable {
private final BigInteger start;
private final BigInteger end;
private final IFinish finish;
public Task(final BigInteger start, final BigInteger end, final IFinish finish) {
this.start = start;
this.end = end;
this.finish = finish;
}
private BigInteger fact(final BigInteger start) {
if (start.equals(this.end)) {
return this.end;
} else {
final BigInteger temp = fact(start.subtract(BigInteger.ONE));
return start.multiply(temp);
}
}
@Override
public void run() {
final BigInteger res = fact(this.start);
if (this.finish != null) {
this.finish.done(res);
}
}
public BigInteger getStart() {
return start;
}
public BigInteger getEnd() {
return end;
}
}