Advertisement
here2share

# proper_base3_length_of_10.py

Sep 17th, 2020 (edited)
1,051
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | None | 0 0
  1. # proper_base3_length_of_10.py
  2.  
  3. def base3(n):
  4.     if n == 0:
  5.         return [0]
  6.     nums = []
  7.     one = False
  8.     if n == 1:
  9.         one = 1
  10.     while n:
  11.         r = n % 3
  12.         n /= 3
  13.         if (n,r) == (0,1) and not one:
  14.             r = 0
  15.         nums.append(int(r))
  16.     return nums[::-1]
  17. 0
  18. i = j = int('1'+'0'*9,3)
  19. o = int('2'*10,3)+1
  20. while i < o:
  21.     print i-j, '\t', base3(i)
  22.     i += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement