text: Sum of all the prime divisors of a number | function to find prime divisors of all numbers from 1 to n ; if the number is prime ; add this prime to all it 's multiples ; Driver code
code: < ? php function Sum ( $ N ) { for ( $ i = 0 ; $ i <= $ N ; $ i ++ ) $ SumOfPrimeDivisors [ $ i ] = 0 ; for ( $ i = 2 ; $ i <= $ N ; ++ $ i ) { if ( ! $ SumOfPrimeDivisors [ $ i ] ) { for ( $ j = $ i ; $ j <= $ N ; $ j += $ i ) { $ SumOfPrimeDivisors [ $ j ] += $ i ; } } } return $ SumOfPrimeDivisors [ $ N ] ; } $ N = 60 ; echo " Sum ▁ of ▁ prime ▁ divisors ▁ of ▁ 60 ▁ is ▁ " . Sum ( $ N ) ; ? >