From 0a13e7b6a5e6275d0d6608acd72e88336e68923f Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 21 Nov 2022 16:18:31 +0100 Subject: [PATCH] python: ex1: add solution --- python/ex1.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 python/ex1.py diff --git a/python/ex1.py b/python/ex1.py new file mode 100755 index 0000000..2b56e33 --- /dev/null +++ b/python/ex1.py @@ -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()