Check if the concatenation of first N natural numbers is divisible by 3 | Java program for the above approach ; Function that returns True if concatenation of first N natural numbers is divisible by 3 ; Check using the formula ; Driver Code ; Given Number ; Function Call
class GFG { static boolean isDivisible ( int N ) { return ( N - 1 ) % 3 != 0 ; } public static void main ( String [ ] args ) { int N = 6 ; if ( isDivisible ( N ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }