Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def convert_base(num, to_base, from_base = 10):
- # first convert to decimal number
- if isinstance(num, str):
- n = int(num, from_base)
- else:
- n = int(num)
- alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- if n < to_base:
- return alphabet[n]
- else:
- return convert_base(n // to_base, to_base) + alphabet[n % to_base]
- def IsPrime(n):
- d = 2
- while d * d <= n and n % d != 0:
- d += 1
- return d * d > n
- a = int(input())
- max_base = 2
- min_count_of_zeros = 0
- for i in range(2,32):
- if IsPrime(i):
- d = convert_base(a,i)
- count_of_zeros = d.count("0")
- if count_of_zeros > min_count_of_zeros:
- max_base = i
- min_count_of_zeros = count_of_zeros
- print(max_base)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement