Is there a test for binary numbers divisible by 2^n - 1?

In summary, the answer to whether a binary number is divisible by three is either testing if the number is a multiple of 11 or 10, or subtracting then adding the bits together.
  • #1
kurtulmehtap
3
0
Dear All,
I have to test if a binary number is divisible to
2^n - 1 where n is even.
Is there a test available for binary numbers like to test a divisibility by 3.
Thanks in advance...
 
Physics news on Phys.org
  • #2
You are talking about what, in general, is studied as Mersenne primes. Even powers are generally not prime. That's not hard to show.
 
Last edited:
  • #3
The sum of the base 2^n digits is divisible by 2^n-1 iff the number is, so you could use that. But I'm not sure how much of a speedup that gives.
 
  • #4
robert Ihnot said:
You are talking about what, in general, is studied as Mersenne primes. Even powers are generally not prime. That's not hard to show.

I interpreted the question as "how can I tell if N is divisible by 2^n-1" rather than "how can I tell if N divides 2^n-1".
 
  • #5
robert Ihnot said:
You are talking about what, in general, is studied as Mersenne primes. Even powers are generally not prime. That's not hard to show.

in my case n is even, not odd or prime
 
  • #6
Testing if a binary number is divisible by three is like testing if a number base 10 is divisible by 11. Alternately subtract than add the bits together and if your answer is divisable by three than the whole string was divisable by three.

1100101 1-1+0-0+1-0+1=2 not divisible by 3
1100110 1-1+0-0+1-1+0=0 divisible by three.
 
  • #7
robert2734 said:
Testing if a binary number is divisible by three is like testing if a number base 10 is divisible by 11. Alternately subtract than add the bits together and if your answer is divisable by three than the whole string was divisable by three.

1100101 1-1+0-0+1-0+1=2 not divisible by 3
1100110 1-1+0-0+1-1+0=0 divisible by three.

3 is a funny number, since it's 2^1 + 1 and 2^2 - 1. You can use either type of test: add digits in blocks of two, or alternately add and subtract digits.

10101011 = 10+10+10+11 = 1001 = 10 + 01 = 11 = 0 (mod 3)
10101011 -> 1-0+1-0+1-0+1-1 = 11 = 0 (mod 3)

The first preserves residues (not just divisibility) mod 3; the second works with smaller numbers (though twice as many).
 
  • #8
You can test if a number base 4 is a multiple of three the way you test if a number base ten is a multiple of nine. I saw your earlier post and decided to add some additional information. I don't know which approach , if either, gives you any calculating speed up.
 

1. What is the formula for "Binary 2^n - 1 divisibility"?

The formula for "Binary 2^n - 1 divisibility" is 2^n - 1 = (2^n - 1) / (2 - 1).

2. What does the "n" represent in "Binary 2^n - 1 divisibility"?

The "n" represents the number of digits in the binary number. For example, if n is 4, the binary number would have 4 digits (e.g. 1111).

3. How do you determine if a binary number is divisible by 2^n - 1?

A binary number is divisible by 2^n - 1 if the sum of its digits is also divisible by 2^n - 1. In other words, the remainder of the binary number divided by 2^n - 1 should be 0.

4. Can you provide an example of a binary number that is divisible by 2^n - 1?

One example of a binary number that is divisible by 2^n - 1 is 1111, when n = 4. The sum of its digits is 15, and 15 is divisible by 2^4 - 1, which is 15.

5. How is "Binary 2^n - 1 divisibility" used in computer science?

In computer science, "Binary 2^n - 1 divisibility" is used in error detection and correction codes, such as the Hamming code. It is also used in cryptography for generating large prime numbers.

Similar threads

  • Linear and Abstract Algebra
Replies
2
Views
437
  • Linear and Abstract Algebra
Replies
14
Views
1K
  • Linear and Abstract Algebra
Replies
10
Views
329
  • Linear and Abstract Algebra
Replies
13
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
804
  • Linear and Abstract Algebra
Replies
4
Views
1K
  • Beyond the Standard Models
Replies
14
Views
2K
  • Linear and Abstract Algebra
Replies
1
Views
578
  • Linear and Abstract Algebra
Replies
6
Views
1K
  • Precalculus Mathematics Homework Help
Replies
5
Views
987
Back
Top