Check if the concatenation of first N natural numbers is divisible by 3 | C ++ 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
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool isDivisible ( int N ) { return ( N - 1 ) % 3 != 0 ; } int main ( ) { int N = 6 ; if ( isDivisible ( N ) ) cout << ( " Yes " ) ; else cout << ( " No " ) ; return 0 ; }