1
2
3
4
5
6
7
8public
9class Power extends Sequence {
10 private
11 long power;
12
13 private
14 Sequence s;
15
16 public
17 Power(Sequence s, long power) {
18 this.s = s;
19 this.power = power;
20 }
21
22 public
23 long next() {
24 long res = 1;
25 long n = s.next();
26
27 for (long i = 0;
28 i < power;
29 ++i) {
30 res *= n;
31 }
32
33 return
34 res;
35 }
36}
37
38
39