Check whether sum of digits at odd places of a number is divisible by K | function that checks the divisibility of the sum of the digits at odd places of the given number ; if position is odd ; Driver code
< ? php function SumDivisible ( $ n , $ k ) { $ sum = 0 ; $ position = 1 ; while ( $ n > 0 ) { if ( $ position % 2 == 1 ) $ sum += $ n % 10 ; $ n = ( int ) $ n / 10 ; $ position ++ ; } if ( $ sum % $ k == 0 ) return true ; return false ; } $ n = 592452 ; $ k = 3 ; if ( SumDivisible ( $ n , $ k ) ) echo " YES " ; else echo " NO " ; ? >