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);
}
printf("\n");


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:

Ranking and Unranking permutations

I've been a big fan of Skiena's Algorithm Design Manual , I recently found my first edition of the book (although I own the third ed...