Answer to Question #283341 in Python for Swarupa

Question #283341

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.

1
Expert's answer
2021-12-28T13:06:07-0500
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)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS