Number with maximum number of prime factors | Return smallest number having maximum prime factors . ; default value of boolean is false ; Sieve of eratosthenes ; Storing prime numbers . ; Generating number having maximum prime factors . ; Driver Code
< ? php function maxPrimefactorNum ( $ N ) { $ arr = array_fill ( 0 , $ N + 5 , true ) ; for ( $ i = 3 ; $ i * $ i <= $ N ; $ i += 2 ) { if ( $ arr [ $ i ] ) for ( $ j = $ i * $ i ; $ j <= $ N ; $ j += $ i ) $ arr [ $ j ] = false ; } $ prime = array ( ) ; array_push ( $ prime , 2 ) ; for ( $ i = 3 ; $ i <= $ N ; $ i += 2 ) if ( $ arr [ $ i ] ) array_push ( $ prime , $ i ) ; $ i = 0 ; $ ans = 1 ; while ( $ ans * $ prime [ $ i ] <= $ N && $ i < count ( $ prime ) ) { $ ans *= $ prime [ $ i ] ; $ i ++ ; } return $ ans ; } $ N = 40 ; print ( maxPrimefactorNum ( $ N ) ) ; ? >