Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # proper_base3.py
- def base3(n):
- if n == 0:
- return [0]
- nums = []
- one = False
- if n == 1:
- one = 1
- while n:
- r = n % 3
- n /= 3
- if (n,r) == (0,1) and not one:
- r = 0
- nums.append(int(r))
- return nums[::-1]
- 0
- i = 0
- o = int('2'*4,3)+1
- while i < o:
- print i, '\t', base3(i)
- i += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement