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