Friday, February 19, 2010

How odd!

Is the the number 124 (in base 5) odd or even? More generally, how can you tell if a number in any base, is odd or even? (Don't worry about the obvious issues for bases > 10).

Labels:

5 Comments:

Blogger Ragknot said...

124 is 444 in base 5.

But changing the base should not change an even to odd.

5 in base 5 is 10, but it is still and odd number... A rose is a rose....

Am I missing something?

February 19, 2010 9:27 PM  
Anonymous Wizard of Oz said...

124(base 5) = 1*25 + 2*5 + 4 = 39(base 10). So it's odd.
A number in an odd base is odd if there are an odd number of odd digits. (That's 4 odds in one sentence!).
A number in an even base is odd only if the last digit is odd.

February 19, 2010 9:29 PM  
Anonymous Wizard of Oz said...

Alternatively, for an odd base, if the sum of the digits in the number is odd then the number is odd.
Yes, I do think Ragknot is missng something . . .

February 19, 2010 9:33 PM  
Blogger Ragknot said...

Oh, I read the post differently. I read it without the the parentheses.

Is the number 124 odd or even in base 5?

February 19, 2010 9:34 PM  
Blogger Chris said...

Soz about that, I didn't notice the ambiguity.

Wiz got the full answer.

In base b a number N is written:
N = d[n] * b^n + d[n-1] * n^(n-1) + ... + d[1] * b + d[0]

Where d[n] represent the n the "digit" of the number (starting at 0).

In mod 2 =>, if b is even, then
N = d[n] * 0^n + d[n-1] * 0^(n-1) + ... + d[1] * 0 + d[0] = d[0].
So the number is even if the last digit is even.

If b is odd, then b and all powers of b, are divisible by 2 with a remainder of 1 =>
N = d[n] * 1^n + d[n-1] * 1^(n-1) + ... + d[1] * 1 + d[0]
N = d[n] + d[n-1] + ... + d[1] + d[0].
So add the digits. If the sum is odd, then so is the number.

February 19, 2010 10:26 PM  

Post a Comment

Links to this post:

Create a Link

<< Home