tags:

views:

171

answers:

4

I know base 13 is not practical. However, i was checking out The Hitchhiker's Guide to the Galaxy again because todays date is 10/10/10 = 42 in binary. (you know, the answer to the ultimate question of life, the universe, and everything) It takes Deep Thought 7½ million years to compute and check the answer, which turns out to be 42. Unfortunately, The Ultimate Question itself is unknown. Anyways, he said ""Six by nine. Forty two." "That's it. That's all there is.""I always thought something was fundamentally wrong with the universe"

My question is how is 6 x 9 in base 13 = 42?

I know how to convert base 10, 2,16,8 but going from base 10 to base 13 is a mystery to me. I understand that in base 13 that 6 probably =6 and 9 probably =9 S0, it is just a matter of multiplying in base 13?

Can someone work it out? I have found this but doesnt help much

in base 13, 6 13 × 9 13 is actually 4213 
(as 4 × 13 + 2 = 54, i.e. 54 in decimal is 
  equal to 42 expressed in base 13).
+6  A: 

This is a method that can convert a base-10 number to base-13:

Start with a number 9x6=54, we want to find the equivalent of 54 in base 13.

54 / 13 = 4 remainder 2
4  / 13 = 0 remainder 4

and we concatenate the remainders, from bottom-up, 42.

A more general algorithm, start with a decimal number N, we want to find the equivalent of N in base B.

N  / B = a1 remainder r1
a1 / B = a2 remainder r2
....
an / B = 0 remainder rn

and concatenate the digits, bottom-up: rn . ... . r2 . r1

an iterative implementation in Python:

digits = '0123456789abcdefghijklmnopqrstuvwxyz'
def rebase(n, base=2):
    ''' Convert a positive integer to number string with base `base` '''
    s = []
    while n != 0:
        n, rem = divmod(n, base)
        s.append(digits[rem])
    return ''.join(reversed(s))

a recursive implementation in Python:

digits = '0123456789abcdefghijklmnopqrstuvwxyz'
def rebase(n, base=2):
    ''' Convert a positive integer to number string with base `base` '''
    return rebase(n // base, base) + digits[n % base] if n != 0 else ''

even more generally, if you have a string representing a number in base N and you want to convert it to a string representing the number in base M:

digits = '0123456789abcdefghijklmnopqrstuvwxyz'
def rebase(orig, orig_base=10, target_base=2):
    ''' Convert a positive integer to number string with base `base` '''
    num = 0
    for i, n in enumerate(reversed(orig)):
        num += digits.find(n) * (orig_base**i)
    target = []
    while num != 0:
        num, rem = divmod(num, target_base)
        target.append(digits[rem])
    return ''.join(reversed(target))
Lie Ryan
+1  A: 

It's not a matter of multplying a number in a different base, but about expressing the product in that base

Lets start with a really easy base, unary, which is expressed in only ones (not even zeroes)

6x9 in unary is 111111 x 111111111. we can perform that calculation by replacing all of the ones in one term with the ones in the other term. copy and paste the nine ones six times

111111111111111111111111111111111111111111111111111111

When we want to express this number in more convenient bases, we group the ones by the radix. If there are enough groups to group the groups, we group them. we then replace the counts of groups with digits. We'll do that in decimal

111111111111111111111111111111111111111111111111111111
         ^         ^         ^         ^         ^

Each arrow is a group of 10, and there are 4 ones left over, so in the tens place, we put a 5 and in the ones place a 4, 54.

lets do the same for a smaller base so we can get a good idea how to generalize the groups of groups:

1  111111111111111111111111111111111111111111111111111111
2   ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
4     ^   ^   ^   ^   ^   ^   ^   ^   ^   ^   ^   ^   ^
8         ^       ^       ^       ^       ^       ^
16                ^               ^               ^
32                                ^

We could make groups five times. starting in the ones place, there we no left over ones after we grouped by two, so the first digit is 0. when we grouped by 4, there was still a group of 2 left over, so the next digit is a 1. when we grouped by 8, there was still a group of 4 left over, another 1 is the next digit. when we grouped by 16, there was one remaining group of 8. when grouping by 32, there's a group of 16 left. we can't make a group of anything as large as 64, so all of the digits for places above 32 are 0. so the binary representation would be

110110

finally, base 13. this is just as easy as the base 10

111111111111111111111111111111111111111111111111111111
            ^            ^            ^            ^

there are 4 groups of 13. there are two digits left over after we make those 4 groups. thus the product of 6 x 9, when represented in base 13 is '42'

TokenMacGuy
A: 

The Answer 42 has nothing to do with base 13, it was just a computational error.

The answer to this is very simple. It was a joke. It had to be a number, an ordinary, smallish number, and I chose that one. Binary representations, base thirteen, Tibetan monks are all complete nonsense. I sat at my desk, stared into the garden and thought '42 will do'. I typed it out. End of story.

http://en.wikipedia.org/wiki/Answer_to_the_Ultimate_Question_of_Life,_the_Universe,_and_Everything#Answer_to_the_Ultimate_Question_of_Life.2C_the_Universe_and_Everything_.2842.29

Nestor
A: 

Counting from one to fifty in base 10:

 1  2  3  4  5  6  7  8  9 10
11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30
31 32 33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48 49 50

Counting from one to fifty in base 13:

 1  2  3  4  5  6  7  8  9  A  B  C 10
11 12 13 14 15 16 17 18 19 1A 1B 1C 20
21 22 23 24 25 26 27 28 29 2A 2B 2C 30
31 32 33 34 35 36 37 38 39 3A 3B 3C 40
41 42 43 44 45 46 47 48 49 4A 4B 4C 50

From the base 13 table just take 9 six times:

1x9: 1  2  3  4  5  6  7  8  9

2x9: A  B  C 10 11 12 13 14 15

3x9: 16 17 18 19 1A 1B 1C 20 21

4x9: 22 23 24 25 26 27 28 29 2A

5x9: 2B 2C 30 31 32 33 34 35 36

6x9: 37 38 39 3A 3B 3C 40 41 42
captaintokyo