Sphenic Number | Create a global array of size 1001 ; ; This functions finds all primes smaller than ' limit ' using simple sieve of eratosthenes . ; Initialize all entries of it as True . A value in mark [ p ] will finally be False if ' p ' is Not a prime , else True . ; One by one traverse all numbers so that their multiples can be marked as composite . ; If p is not changed , then it is a prime ; Update all multiples of p ; To store the 8 divisors ; To count the number of divisor ; Finally check if there re 8 divisor and all the numbers are distinct prime no return 1 else return 0 ) ; ; Driver code
arr = [ True ] * ( 1001 ) NEW_LINE def simpleSieve ( ) : NEW_LINE INDENT k = 0 NEW_LINE for p in range ( 2 , 1001 ) : NEW_LINE INDENT if ( p * p > 1001 ) : NEW_LINE INDENT break NEW_LINE DEDENT if ( arr [ p ] ) : NEW_LINE INDENT for k in range ( p , 1001 , k + p ) : NEW_LINE INDENT arr [ k ] = False NEW_LINE DEDENT DEDENT DEDENT DEDENT def find_sphene ( N ) : NEW_LINE INDENT arr1 = [ 0 ] * ( 8 ) NEW_LINE count = 0 NEW_LINE j = 0 NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT if ( N % i == 0 and count < 8 ) : NEW_LINE INDENT count += 1 NEW_LINE arr1 [ j ] = i NEW_LINE j += 1 NEW_LINE DEDENT DEDENT if ( count == 8 and ( arr [ arr1 [ 1 ] ] and arr [ arr1 [ 2 ] ] and arr [ arr1 [ 3 ] ] ) ) : NEW_LINE INDENT return 1 ; NEW_LINE DEDENT return 0 ; NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 60 NEW_LINE simpleSieve ( ) NEW_LINE ans = find_sphene ( n ) NEW_LINE if ( ans == 1 ) : NEW_LINE INDENT print ( " Yes " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " NO " ) NEW_LINE DEDENT DEDENT