From 7d875084bbe035ee330aa816afd28dbc3cf3dec8 Mon Sep 17 00:00:00 2001 From: Chandra Shakhar <89743498+ChandraShakhar4109@users.noreply.github.com> Date: Wed, 18 Oct 2023 22:48:21 +0530 Subject: [PATCH] Create Weird Algorithm.py --- Weird Algorithm.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Weird Algorithm.py diff --git a/Weird Algorithm.py b/Weird Algorithm.py new file mode 100644 index 0000000..2bc65bb --- /dev/null +++ b/Weird Algorithm.py @@ -0,0 +1,13 @@ +# Weird Algorithm problem link and solution from CSES +#https://cses.fi/problemset/task/1068/ + +n=int(input()) +l=[n] +while(n!=1): + if(n%2==0): + n=int(n/2) + l.append(n) + else: + n=n*3+1 + l.append(n) +print(*l)