human
Distinct Prime Factors of an Array | Function to return an array of prime numbers upto n using Sieve of Eratosthenes.
Function to return distinct prime factors from the given array.
Creating an empty array to store distinct prime factors.
Iterating through all the prime numbers and check if any of the prime numbers is a factor of the given input array.
Driver code.
Finding prime numbers upto 10000 using Sieve of Eratosthenes"
Solution in Python:
 ... Can you provide a code to distinct Prime Factors of an Array and the other steps required?
assistant
#Here is code to distinct Prime Factors of an Array and the other steps required.
 def sieve ( n ) :
	prime = [ True ] * ( n + 1 )
	p = 2
	while ( p * p <= n ) :
		if ( prime [ p ] == True ) :
			for i in range ( p * p , n + 1 , p ) :
				prime [ i ] = False
		p += 1
	allPrimes = [ x for x in range ( 2 , n ) if prime [ x ] ]
	return allPrimes
def distPrime ( arr , allPrimes ) :
	list1 = list ( )
	for i in allPrimes :
		for j in arr :
			if ( j % i == 0 ) :
				list1 . append ( i )
				break
	return list1
if __name__ == " _ _ main _ _ " :
	allPrimes = sieve ( 10000 )
	arr = [ 15 , 30 , 60 ]
	ans = distPrime ( arr , allPrimes )
	print ( ans )