factors Program In Python

            

        Factors Program In Python


the factors of number 10 are

1 * 10 = 10

2 * 5 = 10

5* 2 = 10

10* 1 = 10

Program:

    n = int(input("Enter a number : "))
    count = 0
    for i in range(1, n+1, 1):
        if(n % i == 0):
            count = count + 1
            print(i, end = " ")
    print("\nTotal factors of",n," is :",count)

    OutPut:
    Enter a number : 10
    1 2 5 10 
    Total factors of 10 : 4

    Enter a number : 20
    1 2 4 5 10 20 
    Total factors of 20  is : 6



















    No comments:

    Post a Comment