Thursday, January 13, 2005

Interesting Puzzles - 2

Let f(n) = no of ones required to write numbers from 0 to n. Find the smallest n > 1 such that f(n) = n.

Updating with MN's addition:

Let S = {n | f(n) = n}. Prove: S is finite. Find: |S|

Ah, the good old college days :). If this seems vague or wierd, lookup CLR on complexity analysis.

4 comments:

Vishal Grover said...

which base?

Anonymous said...

Puzzle 2b.
(f defined as above and assume decimal notation)
Let S = {n | f(n) = n}
Prove: S is finite
Find: |S|

-MN

Kalyan said...

The base is 10. eg. f(1) = 1 , f(9) = 1, f(10) = 2 etc.

Kalyan said...

Thanks, I am doing fine.. Writing a script was my first shot too :) [correct answer]. However, you can attempt it mathematically as well by setting up a recurrance and then studying its properties. Dont want to discuss the answer in comments as it will spoil the fun for others.