Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def to(num, base):
- newNum = ''
- while num > 0:
- newNum = str(num % base) + newNum
- num //= base
- return newNum
- n = int(input())
- var=0
- for i in range(9 ** n):
- s9 = to(i, 9)
- if len(s9) == 0:
- continue
- if s9[0] == '0' or len(s9) != n:
- continue
- s3 = to(i, 3)
- if '0' not in s3:
- var+=1
- print(var)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement