Program for Product of unique prime factors of a number

import math

def productPrimeFactors(n):

product = 1

if (n % 2 == 0):

product *= 2

while (n%2 == 0):

n = n/2

for i in range (3, int(math.sqrt(n)), 2):

if (n % i == 0):

product = product * i

while (n%i == 0):

n = n/i

if (n > 2):

product = product * n

return product

n = 44

print (int(productPrimeFactors(n)))


No comments: