You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
from functools import reduce,partialfrom operator import mul# from math import fmoddef _base(n,b): out =[] while n: out.insert(0,n%b) n //= b return out
def _multbase(n,bases): if reduce(mul,bases) < n: raise ValueError("Not enough bases/not big enough") for base in reversed(bases): out.insert(0,n%bases) n //= base if not n: return outdef _fbase(n,b,se = 2**-64): out = [] if b < 1: b = 1/b op = out.append else: op = partial(out.insert,0) print(b) r = 1 while n > r != 0: r = int(n%b) op(r) n = (n-r)/b return outdef _fmultbase(n,b,se = 0.01): out = [] if reduce(mul,bases) < n: raise ValueError("Not enough bases/not big enough") for base in reversed(bases): out.insert(0,n%base) n /= base if n < se or n == 0: return out#test
|