Weird numbers: Difference between revisions

→‎Functional Python: Moved predicate into definition of series
m (→‎Functional Python: Simplified formulation in terms of concatMap)
(→‎Functional Python: Moved predicate into definition of series)
Line 1,464:
(Abundant, but not semi-perfect)
'''
def go(xn):
returnds [x]= if isWeirddescPropDivs(xn) else []
d = sum(ds) - n
return [n] if 0 < d and not hasSum(d, ds) else []
return concatMap(go)(count(1))
 
 
# isWeird :: Int -> Bool
def isWeird(n):
'''Predicate :: abundant and not semi-perfect ?'''
ds = descPropDivs(n)
d = sum(ds) - n
return 0 < d and not hasSum(d, ds)
 
 
9,655

edits