34 lines
483 B
Text
34 lines
483 B
Text
import extensions;
|
|
|
|
public FibonacciGenerator
|
|
{
|
|
yieldable next()
|
|
{
|
|
long n_2 := 1l;
|
|
long n_1 := 1l;
|
|
|
|
$yield n_2;
|
|
$yield n_1;
|
|
|
|
while(true)
|
|
{
|
|
long n := n_2 + n_1;
|
|
|
|
$yield n;
|
|
|
|
n_2 := n_1;
|
|
n_1 := n
|
|
}
|
|
}
|
|
}
|
|
|
|
public program()
|
|
{
|
|
auto e := new FibonacciGenerator();
|
|
|
|
for(int i := 0, i < 10, i += 1) {
|
|
console.printLine(e.next())
|
|
};
|
|
|
|
console.readChar()
|
|
}
|