Project Euler #3: Largest prime factor

  • + 0 comments

    You can use Unitextify for different font styles. However, the solution to problem is:

        # Start with the smallest prime factor
        factor = 2
        while factor * factor <= n:
            if n % factor == 0:
                n //= factor
            else:
                factor += 1
        return n
    
    t = int(input("Enter number of test cases: "))
    for _ in range(t):
        n = int(input())
        print(largest_prime_factor(n))