Elements of Array which can be expressed as power of prime numbers | Function to mark all the exponent of prime numbers ; If number is prime then marking all of its exponent true ; Function to display all required elements ; Function to print the required numbers ; To find the largest number ; Function call to mark all the Exponential prime nos . ; Function call ; Driver code
def ModifiedSieveOfEratosthenes ( N , Expo_Prime ) : NEW_LINE INDENT primes = [ True ] * N ; NEW_LINE for i in range ( 2 , N ) : NEW_LINE INDENT if ( primes [ i ] ) : NEW_LINE INDENT no = i ; NEW_LINE while ( no <= N ) : NEW_LINE INDENT Expo_Prime [ no ] = True ; NEW_LINE no *= i ; NEW_LINE DEDENT for j in range ( i * i , N , i ) : NEW_LINE INDENT primes [ j ] = False ; NEW_LINE DEDENT DEDENT DEDENT DEDENT def Display ( arr , Expo_Prime , n ) : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT if ( Expo_Prime [ arr [ i ] ] ) : NEW_LINE INDENT print ( arr [ i ] , end = " ▁ " ) ; NEW_LINE DEDENT DEDENT DEDENT def FindExpoPrime ( arr , n ) : NEW_LINE INDENT max = 0 ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( max < arr [ i ] ) : NEW_LINE INDENT max = arr [ i ] ; NEW_LINE DEDENT DEDENT Expo_Prime = [ False ] * ( max + 1 ) ; NEW_LINE ModifiedSieveOfEratosthenes ( max + 1 , Expo_Prime ) ; NEW_LINE Display ( arr , Expo_Prime , n ) ; NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT arr = [ 4 , 6 , 9 , 16 , 1 , 3 , 12 , 36 , 625 , 1000 ] ; NEW_LINE n = len ( arr ) ; NEW_LINE FindExpoPrime ( arr , n ) ; NEW_LINE DEDENT