Advertisement
Korotkodul

сис-мы счисления python

Mar 11th, 2022
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. def to(num, base):
  2. newNum = ''
  3.  
  4. while num > 0:
  5. newNum = str(num % base) + newNum
  6. num //= base
  7.  
  8. return newNum
  9.  
  10.  
  11. n = int(input())
  12. var=0
  13. for i in range(9 ** n):
  14. s9 = to(i, 9)
  15. if len(s9) == 0:
  16. continue
  17. if s9[0] == '0' or len(s9) != n:
  18. continue
  19. s3 = to(i, 3)
  20. if '0' not in s3:
  21. var+=1
  22. print(var)
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement