Provide a class SquareSequence
that implements the Sequence
interface from the preceding problem and that yields an infinite sequence of integers 1, 4, 9, 16, 25, 36, ..., of perfect squares.
Provide a class FibSequence
that implements the Sequence
interface from the preceding problem and that yields an infinite sequence of integers 1, 1, 2, 3, 5, 8, 11, 19, ..., of Fibonacci numbers.
Also provide a static method range
of the Sequence
interface that produces an instance of RangeSequence
, a sequence of integers between two bounds. For example, Sequence.range(0, 10)
should yield a sequence with elements 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.