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.

I've searched around but can't seem to find anything relevant. Given a natural number $n$, is there a closed-form formula that gives a decimal number (whose digits consist only of ones and zeros) which, when interpreted as a bit string, equals $n$? What about the reverse?

share|improve this question
    
This gives an algorithm, but not a "closed-form formula". –  Srivatsan Sep 13 '11 at 1:19
1  
Are you asking if it's possible to convert a natural number to binary? –  mixedmath Sep 13 '11 at 1:20
1  
@mixedmath: No, I'm asking if there's an expression for the function {(0, 0), (1, 1), (2, 10), (3, 11), ...}. It's got an interesting graph and I was curious if there were some clever formula in terms of logarithm and modulus. –  Jon Purdy Sep 13 '11 at 1:25
2  
OEIS has some suggestions for formulas, none particularly pretty. –  Henning Makholm Sep 13 '11 at 1:45
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.