python: ex1: add solution
This commit is contained in:
parent
34e5d87379
commit
0a13e7b6a5
19
python/ex1.py
Executable file
19
python/ex1.py
Executable file
|
@ -0,0 +1,19 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from typing import Iterator
|
||||||
|
|
||||||
|
|
||||||
|
def multiples_of(n: int, max: int) -> Iterator[int]:
|
||||||
|
assert n > 0, f"n must be striclyt positive, got: {n}"
|
||||||
|
i = 0
|
||||||
|
while i < max:
|
||||||
|
yield i
|
||||||
|
i += n
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
print(sum(multiples_of(3, 102030)))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
Reference in a new issue