Counting number contain 14 on n-digit number less than 1 second(yodi.polatic.me)
yodi.polatic.me
Counting number contain 14 on n-digit number less than 1 second
http://yodi.polatic.me/counting-number-contain-14-on-digit-number-in-less-than-1-second/
http://yodi.polatic.me/counting-number-contain-14-on-digit-number-in-less-than-1-second/
Instead, it counts the number of numbers in a range which have a "14" in the base-10 expression, using Python code like:
Followed by a more clever recursive solution:
It ended there, but I'll continue a bit further. As with the recursive Fibonacci implementation, this takes exponential time in n - try counting(100). A linear rewrite gives:
where counting2(100) = 6339...7499