Godtone (talk | contribs)
m addition and subtraction for completeness
Godtone (talk | contribs)
→My Python 3 code: subtle bug in additive arithmetic
Line 621: Line 621:
return unfact_int([max(n,0) for n in f],p), unfact_int([-min(d,0) for d in f],p)
return unfact_int([max(n,0) for n in f],p), unfact_int([-min(d,0) for d in f],p)
def iv(n, d, p=None): # provides automatic reduction to simplest form
def iv(n, d, p=None): # provides automatic reduction to simplest form
if n==0:
return (0, 1)
return unfact(fact( (n,d),p ),p)
return unfact(fact( (n,d),p ),p)
def striv(n, d=None): # accepted formats: [(n, d, s)], [(n, d), s], [n, d], [n=h]
def striv(n, d=None): # accepted formats: [(n, d, s)], [(n, d), s], [n, d], [n=h]