From aaa1d28879ae5eeb0591c48ad568444a5cb9b5c8 Mon Sep 17 00:00:00 2001 From: Stefano Agnelli Date: Thu, 26 Sep 2024 23:52:58 +0200 Subject: [PATCH] solution m2-019 --- .../019-the-collatz-conjecture/python/main.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/projects/019-the-collatz-conjecture/python/main.py b/projects/019-the-collatz-conjecture/python/main.py index e69de29..2b9d8e0 100644 --- a/projects/019-the-collatz-conjecture/python/main.py +++ b/projects/019-the-collatz-conjecture/python/main.py @@ -0,0 +1,18 @@ +sequence = 1 + +while sequence > 0: + sequence = int(input('insert an integer: ')) + + while sequence > 1: + is_even = sequence % 2 + + if is_even == 0: + sequence = sequence // 2 + print(sequence) + + else: + sequence = sequence * 3 + 1 + print(sequence) + + +