Check whether product of digits at even places is divisible by sum of digits at odd place of a number | C # implementation of the above approach ; Below function checks whether product of digits at even places is divisible by sum of digits at odd places ; Converting integer to string ; Traveersing the string ; Driver code
using System ; class GFG { static bool productSumDivisible ( int n ) { int sum = 0 ; int product = 1 ; string num = n . ToString ( ) ; for ( int i = 0 ; i < num . Length ; i ++ ) { if ( i % 2 != 0 ) { product = product * ( int ) Char . GetNumericValue ( num [ i ] ) ; } else { sum = sum + ( int ) Char . GetNumericValue ( num [ i ] ) ; } } if ( product % sum == 0 ) { return true ; } else { return false ; } } static public void Main ( ) { int n = 1234 ; if ( productSumDivisible ( n ) ) { Console . WriteLine ( " TRUE " ) ; } else { Console . WriteLine ( " FALSE " ) ; } } }