Check if any large number is divisible by 17 or not | CPP Program to validate the above logic ; Function to check if the number is divisible by 17 or not ; Extracting the last digit ; Truncating the number ; Subtracting the five times the last digit from the remaining number ; Return n is divisible by 17 ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool isDivisible ( long long int n ) { while ( n / 100 ) { int d = n % 10 ; n /= 10 ; n -= d * 5 ; } return ( n % 17 == 0 ) ; } int main ( ) { long long int n = 19877658 ; if ( isDivisible ( n ) ) cout << " Yes " << endl ; else cout << " No " << endl ; return 0 ; }