Interpretation of the comment in sequence A082404

31 views
Skip to first unread message

Ramon Ortega

unread,
Apr 15, 2026, 8:08:00 PM (9 days ago) Apr 15
to SeqFan

If you write down 0 when dividing by 2, 1 when subtracting 1, the trajectory gives the binary expansion of n. Could someone tell me if this comment is correct, that is, if it's possible to arrive at the binary expansion of n by following the procedure of writing down one when subtracting and zero when dividing by two?

Gareth McCaughan

unread,
Apr 15, 2026, 8:57:51 PM (9 days ago) Apr 15
to seq...@googlegroups.com
On 16/04/2026 01:07, Ramon Ortega wrote:

If you write down 0 when dividing by 2, 1 when subtracting 1, the trajectory gives the binary expansion of n. Could someone tell me if this comment is correct, that is, if it's possible to arrive at the binary expansion of n by following the procedure of writing down one when subtracting and zero when dividing by two?

It's right in spirit but a couple of the details are wrong. Here's the right version:

When you subtract 1, the next thing you do will always be to divide by 2. You need to write down a 1 for each (subtract 1 then divide by 2) operation and a 0 for each other (divide by 2) operation. And you continue not until reaching _1_ but until reaching _0_. (You'll always reach 0 by subtracting 1; at that point you actually don't halve next because you're done; but write down a 1 anyway.) Then you'll get the binary expansion of the starting number, read from right to left.

For instance, suppose you start with 13 whose binary representation is 1101. It goes like this:

13 is odd, so subtract 1; 12 is even, so halve. Write down 1.

6 is even, so half. Write down 0.

3 is odd, so subtract 1; 2 is even, so halve. Write down 1.

1 is odd, so subtract 1. (And, if you like, halve 0 to get 0.) Write down 1.

So you've written 1, 0, 1, 1: the digits of 13's binary representation, read from right to left.

-- 
g

Ramon Ortega

unread,
Apr 16, 2026, 8:08:29 AM (8 days ago) Apr 16
to SeqFan
So subtract one and divide by two --> 1
Just dividing by two --> 0

Now I understand.
Thank you very much, Gareth McCaughan!
Reply all
Reply to author
Forward
0 new messages