Ram loves playing with integers.He has a positive integer N.He wants to find special factors of the number.A factor is a number which exactly divides the given number.A factor is special if it is a prime number.Help Ram by identifying all special factors of the number.
import math
num = int(input("Ram, enter an integer number: "))
s = set()
def prime_fator(num):
while num % 2 == 0:
s.add(2)
num = num / 2
for i in range(3,int(math.sqrt(num))+1,2):
while (num % i == 0):
s.add(i)
num = num / i
if num > 2:
s.add(int(num))
prime_fator(num)
print("The special factors are", *s)
Comments
Leave a comment