Check if a large number is divisible by 2 , 3 and 5 or not | C # program to Check if a large number is divisible by 2 , 3 and 5 or not . ; function to return sum of digits of a number ; function to Check if a large number is divisible by 2 , 3 and 5 or not ; Driver code
using System ; class GFG { static int SumOfDigits ( String str , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += ( int ) ( str [ i ] - '0' ) ; return sum ; } static bool Divisible ( String str , int n ) { if ( SumOfDigits ( str , n ) % 3 == 0 && str [ n - 1 ] == '0' ) return true ; return false ; } public static void Main ( ) { String str = "263730746028908374890" ; int n = str . Length ; if ( Divisible ( str , n ) ) Console . WriteLine ( " YES " ) ; else Console . WriteLine ( " NO " ) ; } }