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

Enter any Number : 12

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

CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad