Check if a large number is divisibility by 15 | C # program to check if a large number is divisible by 15 ; function to check if a large number is divisible by 15 ; length of string ; check divisibility by 5 ; Sum of digits ; if divisible by 3 ; Driver code
using System ; class GFG { public static bool isDivisible ( String S ) { int n = S . Length ; if ( S [ n - 1 ] != '5' && S [ n - 1 ] != '0' ) return false ; int sum = 0 ; for ( int i = 0 ; i < S . Length ; i ++ ) sum += ( int ) S [ i ] ; if ( sum % 3 == 0 ) return true ; else return false ; } public static void Main ( ) { String S = "15645746327462384723984023940239" ; if ( isDivisible ( S ) == true ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; String S1 = "15645746327462384723984023940235" ; if ( isDivisible ( S1 ) == true ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }