Question:Write a python program to find the factors of a given number

**Program:**

1 2 3 4 5 6 7 8 9 10 11 12 |
# Python Program to find the factors of a number # This function takes a number and prints the factors def factors(x): print "The factors of",x,"are:" for i in range(1, x + 1): if x % i == 0: print i n = int(input("Enter a number: ")) factors(n) |

**Explanation:**

The **factors of a number** are any **numbers** that divide into it exactly. This includes 1 and the **number** itself. For example, the **factors** of 6 are 1, 2, 3 and 6. The **factors **of 8 are 1, 2, 4 and 8. For larger **numbers** it is sometimes easier to ‘pair’ the **factors **by writing them as multiplications.

**Output:**

1 2 3 4 5 6 7 8 9 10 11 |
Enter a number: 10 The factors of 10 are: 1 2 5 10 |

Do share your feedback in comments to help us adding more programs like this.

## Leave a Reply