import math


def largest_prime_factor_square_optimized(number):
    """
    Every number n can at most have one prime factor greater than n.

    If we, after dividing out some prime factor, calculate the square root of the remaining number
    we can use that square root as upper limit for factor.
    
    If factor exceeds this square root we know the remaining number is prime.
    """
    factors = []
    factor = 2
    if number % factor == 0:
        number = number // factor
        factors.append(factor)
        while number % factor == 0:
            number = number // factor

    factor = 3
    max_factor = math.sqrt(number)
    while number > 1 and factor <= max_factor:
        if number % factor == 0:
            factors.append(factor)
            number = number // factor
            while number % factor == 0:
                number = number // factor
                max_factor = math.sqrt(number)
        factor += 2

    return factors