def max_divisor_less_or_equal_sqrt(n): factors = factor(n) max_factor = sqrt(n) divisors = [1] for [p, k] in factors: addon = [] for i in range(1,k+1): addon += map(lambda(x) : x * (p**i), divisors) divisors += addon divisors = filter(lambda(x) : x <= max_factor, divisors) divisors = sorted(divisors) max_divisor = divisors[len(divisors) - 1] return max_divisor
def numberOfFactors(n): return len(factor(n))