Programming Examples

Python program to print factor of given number


Write a Python program to input any number and print all factors of input number.

A factor is a number that divides into another number exactly and without leaving a remainder.

Sample:

Input : 12

Output : Factor of 12 are : 1,2,3,4,6 ,12 

Solution

num=int(input("Enter any Number : "))
print("Factor of ",num," are : ",end='')
for a in range(1,num):
    if num%a==0:
        print(a,end=',')
print(num)
Output/ Explanation:

Enter any Number : 12

Factor of  12  are : 1,2,3,4,6,12

Latest Current Affairs 2024 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad