Processing math: 100%
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

answered 3 years ago

Max Alekseyev gravatar image

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)) )
click to hide/show revision 2
No.2 Revision

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)) )