Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x = int(input())
- a = []
- if x == 1:
- print("0")
- elif x == 2:
- print("1")
- elif x == 3:
- print("1")
- else:
- a = [0] * (x + 1)
- a[1] = 0
- a[2] = 1
- a[3] = 1
- for i in range(4, x + 1):
- a[i] = a[i-1] + 1
- if i % 3 == 0:
- if a[i] > a[i//3] + 1:
- a[i] = a[i//3] + 1
- if i % 2 == 0:
- if a[i] > a[i//2] + 1:
- a[i] = a[i//2] + 1
- print(a[x])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement