Let\'s define eleven-non-free
numbers:
If we consider a number as a string, then if any substring inside is a (non-zero) power of 11
, then this
10^18
is really, really big. Brute force is not your friend.
However, let us note some conveniences:
s
represents a eleven-non-free number, then trivially so does d s
(where d
is a string of digits).k
-digit numbers are eleven-non-free, you could base that off of how many k-1
-digit numbers are eleven-non-free.Finally, throw some binary-search style logic on top, and you should be able to find exactly which number is the N-th eleven-non-free number.
given a k, find the kth eleven-non-free number.
...
is a big question.
Since this is time taking question, I am writing pseudo code.
var eleven_powers = [];
for (var i=0; i<1000; i++)
eleven_powers.push(Math.pow(11,i));
non-eleven-free
numbers to an extent you can. This will have to deal with big integers.for (var i=11; i<Integer.MAX_VALUE; i++){
if(string(i).substring(for each of eleven_powers) == true)
store it sequentially results_array
}
Take k, return results_array[k]