- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Divisibility by 64 with removal of bits allowed in C++ Program

In this tutorial, we are going to write a program that checks whether the given binary number is divisible by 64 or not.

We have given a binary number and we can remove the bits to make it divisible by 64. After removing the bits, if the number is divisible by 64, then print **Yes** else **No**.

The method that we are going to use is very simple. Let's see the steps to solve the problem.

Initialize the binary number in string format.

Iterate over the given binary number.

Count the number of zeros.

If the binary number contains more than or equal to 6 and there is a 1 bit, then the number is divisible by 64.

Print whether the given binary number is divisible by 64 or not.

## Example

Let's see the code.

#include <bits/stdc++.h> using namespace std; bool isBinaryStringDivisibleBy64(string binary_number, int n) { int zeroes_count = 0; for (int i = n - 1; i >= 0; i--) { if (binary_number[i] == '0') { zeroes_count++; } if (zeroes_count >= 6 && binary_number[i] == '1') { return true; } } return false; } int main() { string binary_string = "100100100100100"; if (isBinaryStringDivisibleBy64(binary_string, 15)) { cout << "Yes" << endl; } else { cout << "No" << endl; } return 0; }

## Output

If you run the above code, then you will get the following result.

Yes

## Conclusion

If you have any queries in the tutorial, mention them in the comment section.

- Related Questions & Answers
- Game of Nim with removal of one stone allowed in C++
- Divisibility by 12 for a large number in C++ Program
- To check divisibility of any large number by 9 in java
- How can I to know if my database MongoDB is 64 bits?
- Numbers obtained during checking divisibility by 7 using JavaScript
- Maximum sum by adding numbers with same number of set bits in C++
- Check if a large number is divisibility by 15 in C++
- Program to find length of longest set of 1s by flipping k bits in Python
- Program to find winner of array removal game in Python
- C++ program to find winner of ball removal game
- Maximum sum of pairwise product in an array with negative allowed in C++ program
- Maximize profit when divisibility by two numbers have associated profits in C++
- Program to find maximum score of brick removal game in Python
- C++ Program to find maximum score of bit removal game
- Check if frequency of all characters can become same by one removal in Python