Datasets:

Modalities:
Text
Formats:
text
Size:
< 1K
Libraries:
Datasets
License:
PyRs2 / python /iterators.py
khulnasoft's picture
Upload folder using huggingface_hub
998b6cc verified
raw
history blame contribute delete
366 Bytes
class Fibonacci:
def __init__(self, limit):
self.limit = limit
self.a, self.b = 0, 1
def __iter__(self):
return self
def __next__(self):
if self.a > self.limit:
raise StopIteration
val = self.a
self.a, self.b = self.b, self.a + self.b
return val
for i in Fibonacci(100):
print(i)