Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Consider a number Q in a made up base system:

The base system is as follows:

It encodes a number as a sum of odd numbers:

1 3 5 7 9 ...

If the number can be expressed as a sum of unique odds. For example, the number 16 is expressed as:

1110 = 7 + 5 + 3 + 1

The system is also redundant as 16 can also be expressed as:

11000

My question:

Given a natural number u, how can u be expressed in this system quickly if u can be expressed in the system, quickly.

share|improve this question
    
If x is an even number (except 2), write 1 + (x-1). If x is an odd number (except 1, 3, 5, 7), write 1 + 3 + (x-4). Or, if you like, x is already a sum of one odd number (x). –  Billy Jul 27 '13 at 2:07

2 Answers 2

If $u$ is odd, write $u$ as the following sum of odd numbers: $$u$$ If $u$ is even (and $\geq 2$), write $u$ as the following sum of odd numbers: $$(u-1)+1$$ (Converting into a string of ones and zeros is straightforward.)

share|improve this answer

If $u$ is even and greater than two: represent $u$ as $110\dots0$, where the number of $0$s is equal to $\frac{u}{2} - 2$.

If $u$ is odd: represent $u$ as $10\dots0$, where the number of $0$s is equal to $\frac{u - 1}{2}$.

$2$ cannot be represented in this system, but is the only nonnegative number for which this is the case.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.