Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

My best shot so far is iterating over the divisors of the radical of $n$ and saturating prime powers in them:

def unitary_divisors4(n):
    fn = factor(n)
    D = {p:(k-1) for p,k in fn if k>1}
    return sorted( prod(p^k for p,k in D.items() if d%p==0)*d for d in divisors(prod(p for p,_ in fn)) )

My best shot so far is iterating over the divisors of the radical of $n$ and saturating prime powers in them:

def unitary_divisors4(n):
    fn = factor(n)
    D = {p:(k-1) [(p,k-1) for p,k in fn if k>1}
k>1]
    return sorted( prod(p^k for p,k in D.items() D if d%p==0)*d for d in divisors(prod(p for p,_ in fn)) )