views:

98

answers:

1

I am trying to solve the problem Secret Code and it's obviously math problem.

The full problem

For those who are lazy to go and read, it's like this:

a0,a1,a2,...,an - sequence of N numbers
B - some number known to us
X = a0 + a1*B + a2*(B^2) + a3*(B^3) + ... + an*(B^n)

So if you are given B and X, you should find a0,a1,..an. I don't know how or where to start, because not even N is known, just X and B.

Can you help me ?

+4  A: 

The key is that a0 .. an are not arbitrary numbers, they're integers (otherwise, this wouldn't be possible in general). You're given the number X , and are asked to express it in base B. Why don't you start by working a few examples for a specific value of B?

If I asked you to write 17 in base 2, would you be able to do that? Can you find a way to generalize the algorithm you use to bases other than 2?

Stephen Canon
Can you clarify your suggestion about expressing in base B ? For your ex, i don't know how to write 17 in base 2 ?
VaioIsBorn
@VaioIsBorn - here's some info about converting between number bases, it should also help you see what the problem asks for: http://www.brainjammer.com/math/bases/ and http://www.math.grin.edu/~rebelsky/Courses/152/97F/Readings/student-binary
IVlad