Problem p02900 (python)

Fixed submission:
import math, fractions


def num_prime_factor(n):
    
    ret = 0

    for i in range(1, int(math.sqrt(n)) + 2):

        composite = False

        if n % i == 0:
            ret += 1
            n = n / i

            if i != 1:
                while n % i == 0:
                    n = n / i

            if n == 1:
                break

            for j in range(2, int(math.sqrt(n)) + 2):
                if n % j == 0:
                    composite = True
                    break

            if not composite:
                ret += 1
                break

    return ret

if __name__ == "__main__":
    A, B = map(int, input().split())
    n = fractions.gcd(A, B)
    print(num_prime_factor(n))

Buggy submission (verdict: Runtime Error):
def main():
    A, B = map(int, input().split())
    while b != 0: A, B = B, A % B 
    print(num_prime_factor(A))

def num_prime_factor(n):
    
    if n == 1: return 1
    
    ret = 1
    cursor = 2
    if n % cursor == 0: ret += 1
    while n % cursor == 0: n = n // cursor
    
    cursor = 3
    while cursor**2 <= n:
        if n == 1: return ret
        if n % cursor == 0: ret += 1
        while n % cursor == 0: n = n // cursor
        cursor += 2

    if n != 1: ret += 1
        
    return ret

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import math, fractions


def main():
    A, B = map(int, input().split())
    n = fractions.gcd(A, B)
    print(num_prime_factor(n))

def num_prime_factor(n):
    
    if n == 1:
        return 1
    
    ret = 1
    curser = 2
    if n % cursor == 0:
        ret += 1
        n = n // cursor
        while n % cursor == 0:
            n = n // cursor
    
    cursor = 3
    if n % cursor == 0:
        ret += 1
        n = n // cursor
        while n % cursor == 0:
            n = n // cursor
        cursor += 2

    if n != 1:
        ret += 1
        
    return ret

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import fractions


def prime_number(n):
    # n >= 2
    N = n + 1
    table = [0] * N
    prime_list = []

    for i in range(2, N):
        if table[i] == 0:
            prime_list.append(i)

            for j in range(i + i, N, i):
                table[j] = 1

    return prime_list

def prime_factor(n):
    prime_list = prime_number(n)
    
    ret = 1
    for i in prime_list:
        if n % i == 0:
            ret +=1
            while n % i == 0:
                n = n // i
            
    return ret

A, B = map(int, input().split())
n = fractions.gcd(A, B)
print(prime_factor(n))

Buggy submission (verdict: Runtime Error):
import fractions


def prime_number(n):
    # n >= 2
    N = n + 1
    table = [0] * N
    prime_list = []

    for i in range(2, N):
        if table[i] == 0:
            prime_list.append(i)

            for j in range(i + i, N, i):
                table[j] = 1

    return prime_list

def prime_factor(n):
    prime_list = prime_number(n)
    
    ret = 1
    for i in prime_list:
        if n % i == 0:
            ret +=1
            while n % i == 0:
                n = n // i
            
    return ret

if __name__ == "__main__":
    A, B = map(int, input().split())
    n = fractions.gcd(A, B)
    print(prime_factor(n))

Buggy submission (verdict: Runtime Error):
import fractions


def prime_number(n):
    N = n + 1
    table = [0] * N
    prime_list = []
    
    for i in range(2, N):
        if table[i] == 0:
            prime_list.append(i)
            
            for j in range(i + i, N, i):
                table[j] = 1
    
    return prime_list

def prime_factor(n):
    prime_list = prime_number(n)
    
    ret = 1
    for i in prime_list:
        if n % i == 0:
            ret +=1
            while n % i == 0:
                n /= i
            
    return ret

if __name__ == "__main__":
    A, B = map(int, input().split())
    n = fractions.gcd(A, B)
    print(prime_factor(n))

Buggy submission (verdict: Runtime Error):
import math, fractions


def prime_number(n):
    N = n + 1
    table = [0] * N
    prime_list = []
    
    for i in range(2, N):
        if table[i] == 0:
            prime_list.append(i)
            
            for j in range(i + i, N, i):
                table[j] = 1
    
    return prime_list

def prime_factor(n):
    prime_list = prime_number(n)
    
    ret = 1
    for i in prime_list:
        if n % i == 0:
            ret +=1
        while n % i == 0:
            n /= i
            
    return ret

if __name__ == "__main__":
    A, B = map(int, input().split())
    n = fractions.gcd(A, B)
    print(prime_factor(n))

Buggy submission (verdict: Runtime Error):
import math, fractions


def prime_number(n, include_one=True):
    N = n + 1
    table = [0] * N
    
    if include_one:
        prime_list = [1]
    else:
        prime_list = []
    
    for i in range(2, N):
        if table[i] == 0:
            prime_list.append(i)
            
            for j in range(i + i, N, i):
                table[j] = i
    
    return prime_list

def prime_factor(n, include_one=True):
    prime_list = prime_number(n, include_one)
    
    ret = 0
    for i in prime_list:
        if n % i == 0:
            ret +=1
            n /= i
            
    return ret

if __name__ == "__main__":
    A, B = map(int, input().split())
    n = fractions.gcd(A, B)
    print(prime_factor(n))