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

  • Context: Undergrad 
  • Thread starter Thread starter kurtulmehtap
  • Start date Start date
  • Tags Tags
    Binary Divisibility
Click For Summary

Discussion Overview

The discussion centers on the methods for testing the divisibility of binary numbers by the expression 2n - 1, particularly when n is even. Participants explore various approaches and comparisons to known divisibility tests, such as those for the number 3.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant inquires about a test for determining if a binary number is divisible by 2n - 1, similar to the divisibility test for 3.
  • Another participant mentions that the topic relates to Mersenne primes and notes that even powers are generally not prime, suggesting a distinction in the nature of n.
  • A suggestion is made that the sum of the base 2n digits can indicate divisibility by 2n - 1, though the efficiency of this method is questioned.
  • Further clarification is provided regarding the interpretation of the original question, focusing on whether N is divisible by 2n - 1 rather than the reverse.
  • Several participants discuss methods for testing divisibility by 3, drawing parallels to base 10 divisibility tests, and provide examples of binary numbers and their calculations.
  • One participant notes that 3 can be represented as both 21 + 1 and 22 - 1, suggesting flexibility in testing methods.
  • Another participant introduces a method for testing base 4 numbers for divisibility by 3, comparing it to base 10 methods for 9, while also expressing uncertainty about the speed of calculations.

Areas of Agreement / Disagreement

Participants express differing views on the interpretation of the divisibility question and the applicability of various tests. There is no consensus on a definitive method for testing divisibility by 2n - 1, and multiple approaches are discussed without resolution.

Contextual Notes

Some limitations include the dependence on the definitions of divisibility and the specific conditions under which the tests are applied. The discussion does not resolve the mathematical steps involved in the proposed methods.

kurtulmehtap
Messages
3
Reaction score
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
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:
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.
 
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".
 
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
 
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.
 
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).
 
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.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 22 ·
Replies
22
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 26 ·
Replies
26
Views
1K
  • · Replies 11 ·
Replies
11
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 2 ·
Replies
2
Views
1K