# Number is divisible by 29 or not in C++

C++Server Side ProgrammingProgramming

#### C in Depth: The Complete C Programming Guide for Beginners

45 Lectures 4.5 hours

#### Practical C++: Learn C++ Basics Step by Step

Most Popular

50 Lectures 4.5 hours

#### Master C and Embedded C Programming- Learn as you go

Best Seller

66 Lectures 5.5 hours

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

## 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
Updated on 26-Oct-2021 06:00:45