Wednesday, February 16, 2005

Answer to Fundamentals of Numbers

In the blog post Fundamentals of Numbers, a fundamental question was posted.

Well here is the hint

Take beta=10 and n = 121

121 = 1 * 10^2 + 2 * 10 + 1

Now try the following C based pseudo-code

while (n/beta) {
printf("%d\t", n % beta);
n /= beta;
if (n % beta) {
printf("%d\n", n % beta);

It prints out the numbers in opposite order. Get it? No matter what the value of n and beta, we can find a sequence representing n in terms of beta.

This should really be an axiom.

No comments:

Dynamic programming for the binomial coefficient

More fun things, this time with some visualisation of what happens when memoisation is used and what happens when we don't. I don'...