Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
19
Task/Fibonacci-sequence/Haxe/fibonacci-sequence-2.haxe
Normal file
19
Task/Fibonacci-sequence/Haxe/fibonacci-sequence-2.haxe
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
class FibIter
|
||||
{
|
||||
private var current = 0;
|
||||
private var nextItem = 1;
|
||||
private var limit:Int;
|
||||
|
||||
public function new(limit) this.limit = limit;
|
||||
|
||||
public function hasNext() return limit > 0;
|
||||
|
||||
public function next() {
|
||||
limit--;
|
||||
var ret = current;
|
||||
var temp = current + nextItem;
|
||||
current = nextItem;
|
||||
nextItem = temp;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue