
This marks the third post in my Linux + Python series. Python, being a versatile scripting language, serves as a perfect experimental platform—one that allows me to explore and indulge in my numerical and mathematical creativity.
A factor of a number:
A factor is a number that divides another number, leaving no remainder. In other words, if multiplying two whole numbers gives us a product, then the numbers we are multiplying are factors of the product because they are divisible by the product. There are two methods of finding factors: multiplication and division.
splashlearn.com
Example:
Let’s take 12 and start dividing the number from 1 to 12.
12/1 = 12
12/2 = 6
12/3 = 4
12/4 = 3
12/5 = 2.4
12/6 = 2
12/7 = 1.7
…. continue it until 12…
As described on SplashLearn.com, a factor of a number is any number that divides it completely, leaving no remainder. For instance, the number 12 has six factors: 1, 2, 3, 4, 6, and 12.
Below is the corresponding Python solution.
Code:
Actual code:
x = int(input("enter a number: "))
print("factor of",x,"is: ")
for i in range(1, x+1):
if x%i==0:
print(i)
In the code above, special attention should be given to the x + 1 in the for loop condition. This increment is essential—without it, the loop will not include the specified number itself. For example, if you choose 12, the loop would otherwise iterate only up to 11. Including +1 ensures that the loop evaluates all numbers from 1 through 12, as intended.
for i in range(1, x+1):
Afterthoughts:
Isn’t it exciting to explore and experiment with STEM through Python? I find the journey both engaging and rewarding. I’ll continue sharing more posts about Python and my experimental projects centered around this STEM-friendly language—so stay tuned!

