It's a straightforward problem. We can use the modulo (%) operator to check whether the given number is divisible by 29 or not. Let's see some examples.
Input
29 254
Output
1 0
Algorithm
Implementation
Following is the implementation of the above algorithm in C++
#include <bits/stdc++.h>
using namespace std;
bool isDivisibleBy29(long long n) {
return n % 29 == 0;
}
int main() {
cout << isDivisibleBy29(29) << endl;
cout << isDivisibleBy29(234567876543) << endl;
cout << isDivisibleBy29(234567657329) << endl;
return 0;
}Output
If you run the above code, then you will get the following result.
1 1 0