Tuesday, March 19, 2013

project euler problem 040

Champernowne's constant

This number appeared at least 3 times in all 400 problems. This is the easiest one. Problem 305 is much more difficult than 40. I used binary search on this problem. Simple and fast. I remember that the first time I saw this problem, I solved it by hand. It is not difficult since the number of digits involved is so small.

Update: Binary search is still an overkill if we use a function to count the numbers of digits up to n. With some simple math, the problem can be further simplified. since the numbers with one digit is 9 and with two digits is 90, etc.

No comments:

Post a Comment