<s>[INST] def check_prime(n):
    if n <= 1:
        return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0:
            return False
    return True

def largest_prime_factor(n):
    max_prime_factor = None
    for i in range(2, n + 1):
        if n % i == 0 and check_prime(i):
            max_prime_factor = i
    return max_prime_factor

def largest_prime_factor_sieve(n):
    sieve = [True] * (n + 1)
    sieve[0] = sieve[1] = False
    for i in range(2, int(n**0.5) + 1):
        if sieve[i]:
            for j in range(i * i, n + 1, i):
                sieve[j] = False
    max_prime_factor = None
    for i in range(2, n + 1):
        if sieve[i] and n % i == 0:
            max_prime_factor = i
    return max_prime_factor

def largest_prime_factor_iterative(n):
    i = 2
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
    return n[/INST]