Advertisement
here2share

# t_zbase_n.py ***

Jan 21st, 2021 (edited)
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. # t_zbase_n.py -- thanks for the help on this, you people are awesome
  2.  
  3. def zbase(n, b=3,length=4):
  4.     b += 1
  5.     if n == 0:
  6.         return [0]*length
  7.     values = []
  8.     for z in 'Z'*length:
  9.         r = n % b
  10.         n = int(n/b)
  11.         values.append(r)
  12.     return values[::-1]
  13. 0
  14. i = 0
  15. while 1:
  16.     t = zbase(i,4,3)
  17.     if not t:
  18.         break
  19.     print i, '\t', t
  20.     i += 1
  21. 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement