Prime Factors

    0

    0

    Mahendra Kumar

    beginnermaths

    To find the prime factors of a given number.

    # take inputs
    num = int(input('Enter number: '))
    # find prime factors
    for i in range(2, num + 1):
        if(num % i == 0):
            isPrime = 1
            for j in range(2, (i //2 + 1)):
                if(i % j == 0):
                    isPrime = 0
                    break
            if (isPrime == 1):
                print(i,end=' ')
    print('are the prime factors of number',num)
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.