text: Check if the sum of digits of a number N divides it | C # program to check if sum of digits of a number divides it ; Function to check if sum of digits of a number divides it ; Calculate sum of all of digits of N ; Driver Code
code: using System ; class GFG { public int isSumDivides ( int N ) { int temp = N , sum = 0 ; while ( temp > 0 ) { sum += temp % 10 ; temp /= 10 ; } if ( N % sum == 0 ) return 1 ; else return 0 ; } public static void Main ( ) { GFG g = new GFG ( ) ; int N = 12 ; if ( g . isSumDivides ( N ) > 0 ) Console . WriteLine ( " YES " ) ; else Console . WriteLine ( " NO " ) ; } }