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'm trying to concisely write an expression for a sequence which flips a switch $n$ times where $n$ is the number of times 2 divides evenly into $n$, so the first 24 values are:

01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
 0  1  0  0  0  1  0  1  0  0  0  0  0  1  0  0  0  1  0  0  0  1  0  1

Is there a name for the "super-evenness" of something?

So far, the best I've been able to do is define the quantity $k$ such that $n = 2^{k}m$ with $n, k, m \in \mathbb{Z}$. You can technically evaluate this by solving the equation $\mathrm{log_{2}}(n) = k + \mathrm{log_{2}}(m)$, though this isn't a particularly useful algorithm.

I suppose this is OK, but it'd be much nicer if there were a simpler function which doesn't involve solving for integers from logarithms. Plus there's a disconnect between that equation, which precisely defines the sequence, and the algorithm people would use to find it (which is going to be 'divide by 2 until you hit an odd number').

share|improve this question
5  
In many places it is called $\mbox{ord}_2(n).$ In other places it is called $v_2(n),$ where the letter $v$ stands for "valuation." The reliable way to find it is to divide by 2 until the result is odd, having kept count of the number of times you did that. Oh, the name is the 2-adic valuation of $n.$ I guess you could make a name out of the word "order." –  Will Jagy Apr 3 '13 at 23:39
    
Perfect! This is basically all I needed. If you want to add this as an answer instead of a comment I can accept it. I had a hunch it was something to do with p-adic, but I'm not a mathematician, so I didn't really know how to find the answer. –  Paul Apr 3 '13 at 23:45
1  
It is easier if you don't count multiplicity. Then the answer is one. :) –  Ross Millikan Apr 3 '13 at 23:46
    
@Ross: My first thought when I saw the title was "I should post a comment that simply says 'One.'" –  Cameron Buie Apr 4 '13 at 0:21

1 Answer 1

up vote 2 down vote accepted

In many places it is called $\mbox{ord}_2(n).$ In other places it is called $v_2(n),$ where the letter $v$ stands for "valuation." The reliable way to find it is to divide by 2 until the result is odd, having kept count of the number of times you did that. Oh, the name is the 2-adic valuation of $n.$ I guess you could make a name out of the word "order."

If a computer is doing it, I would have it take the absolute value of the integer first, then confirm that the number is nonzero, else an infinite loop.

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.