-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
67 lines (50 loc) · 1.34 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
'''
AUTHOR: Andrej Bartulin
PROJECT: 3x
LICENSE: Public Domain
DESCRIPTION: Main file for Python version
'''
import sys
def main(mode: int, n: int) -> int:
previous = 0
max = n
starter = n
if mode == 1:
while 1:
if n == 1:
break
if n % 2 == 0:
n //= 2
print(n)
else:
n *= 3
n +=1
print(n)
print(f"We came to the loop. Number n at start was {starter}, now is: {n}.")
elif mode == 2:
while 1:
if n == 1:
break
if n % 2 == 0:
n //= 2
print(n)
else:
n *= 3
n +=1
print(n)
if n > max:
max = n
previous = n
print(f"We came to the loop. Number n at start was: {starter}, now is: {n}. Max is: {max}.")
else:
print(f"Wrong mode {mode}! Exiting with value 1...")
return 1
return 0
if __name__ == "__main__":
if not len(sys.argv) == 3:
print("Argument error")
mode = int(input("Enter mode: "))
number = int(input("Enter mode: "))
main(mode, number)
else:
main(int(sys.argv[1]), int(sys.argv[2]))