-1

hello there guys i have developed a code which prints the prime factor in limited range but i have not used OOP in this so can you help to make a more efficient version

num1 = int(input('Enter the number'))
i = 0
while i < num1:
i += 1
if i % 2 == 0:
    num1 = i // 2
    print(num1)
elif i % 3 == 0:
    num1 = i //3
    print(num1)
# and so on .....

please help me to make it more versitile

Tanay Kumar
  • 81
  • 1
  • 2
  • 7

1 Answers1

1

Some easy way you can try:

num= input("Enter Any Number:")
def print_factors(inputnumber):
    for i in range(2, inputnumber):
        while inputnumber % i == 0:
            print(i)
            inputnumber /= i
        if inputnumber <= 1:
            break

print_factors(int(num))