# Finding the Factors of a Number

Steinar Martinussen

This was a suprise challenge indeed.

Is the goal to solve this with just the knowledge from this course and its contents ? I might be missing some Python knowledge to make this happen.

The sample code attached to this course is also belonging to another course: Real Python: Functions and Loops course by Philipp Acsany

Martin Breuss RP Team

If you want a walkthrough to a possible solution, then you can check the section in the associated exercises course :)

doink

``````def factor_calculator(num):
internal_num = num
for factor in range(2, 10):
if internal_num % factor == 0:
return factor
else:
continue
return internal_num

number = input("Enter a number: ")

if number.isnumeric():

number = int(number)

if number <= 0:
print("Enter a number greater than 0 ")
else:
num_res = number
factors =[]

factor = factor_calculator(num_res)

while num_res != factor:
factors.append(factor)
num_res = int(num_res / factor)
factor = factor_calculator(num_res)

factors.append(factor)

if len(factors) == 1:
text = ", it's a prime number!"
else:
text = ""

print(f"The {number=} is divided into {factors=}{text}")

else: