Ejemplo n.º 1
0
def is_squarefree(n):
    if n == 1:
        return True

    quotient = n
    count = 1
    while count == 1:
        prime, _ = first_prime_divisor(quotient)
        quotient, count = robust_divide(quotient, prime, include_count=True)
        if quotient == 1:
            return (count == 1)
    return False
Ejemplo n.º 2
0
def all_radicals(n):
    PRIMES = sieve(n)
    result = {1: 1}
    for i in range(2, n + 1):
        if i in PRIMES:
            result[i] = i
        prime, quotient = first_prime_divisor(i, PRIMES)
        if quotient % prime == 0:
            result[i] = result[quotient]
        else:
            result[i] = result[quotient]*prime
    return result