# JavaScript (ES6), <s>47</s> <s>43</s> 42 bytes *-4 bytes thanks to @Arnauld* *-1 byte thanks to @Luke* <!-- language: lang-js --> n=>eval('for(i=0;!/^9+0*$/.test(i);)i+=n') ## Tests <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> let f= n=>eval('for(i=0;!/^9+0*$/.test(i);)i+=n') for(let i=1;i<=16;i++)console.log(`f(${i}) = `+f(i)) <!-- end snippet --> ### Recursive solution (fails for 7, 13, and 14), 38 bytes <!-- language: lang-js --> n=>g=(i=0)=>/^9+0*$/.test(i+=n)?i:g(i) Called like `f(5)()`. Reaches the max call stack size in Chrome and Firefox for `n=7`, `n=13`, and `n=14`. <!-- begin snippet: js hide: true console: true babel: false --> <!-- language: lang-js --> f= n=>g=(i=0)=>/^9+0*$/.test(i+=n)?i:g(i) for(let i=1;i<=16;i++){ try { console.log(`f(${i}) = `+f(i)()) } catch(e) { console.log(`f(${i}) = FAILED`) } } <!-- end snippet -->