★ wanayoo — archive 1999 https://github.com/TheAlgorithms/Java/issues/1874Nouvelle recherche | Portail wanayoo
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a Binary Gap Calculator with Java #1874

Closed
miador opened this issue Oct 19, 2020 · 0 comments
Closed

Adding a Binary Gap Calculator with Java #1874

miador opened this issue Oct 19, 2020 · 0 comments

Comments

@miador
Copy link

@miador miador commented Oct 19, 2020

A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of N.
For example, number 9 has binary representation 1001 and contains a binary gap of length 2.

  • The number 529 has binary representation 1000010001 and contains two binary gaps: one of length 4 and one of length 3.
  • The number 20 has binary representation 10100 and contains one binary gap of length 1.
  • The number 15 has binary representation 1111 and has no binary gaps. The number 32 has binary representation 100000 and has no binary gaps.
@miador miador closed this Oct 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.