Skip to main content
added 37 characters in body
Source Link
Justin Mariner
  • 5k
  • 1
  • 13
  • 18

JavaScript (ES6), 47 4343 42 bytes

-4 bytes thanks to @Arnauld
-1 byte thanks to @Luke

n=>eval('for(i=0;!/^9+0*$/.test(i+=ni););i'i+=n')

Tests

let f=
n=>eval('for(i=0;!/^9+0*$/.test(i+=ni););i'i+=n')

for(let i=1;i<=16;i++)console.log(`f(${i}) = `+f(i))

Recursive solution (fails for 7, 13, and 14), 38 bytes

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.

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`) }
}

JavaScript (ES6), 47 43 bytes

-4 bytes thanks to @Arnauld

n=>eval('for(i=0;!/^9+0*$/.test(i+=n););i')

Tests

let f=
n=>eval('for(i=0;!/^9+0*$/.test(i+=n););i')

for(let i=1;i<=16;i++)console.log(`f(${i}) = `+f(i))

Recursive solution (fails for 7, 13, and 14), 38 bytes

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.

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`) }
}

JavaScript (ES6), 47 43 42 bytes

-4 bytes thanks to @Arnauld
-1 byte thanks to @Luke

n=>eval('for(i=0;!/^9+0*$/.test(i);)i+=n')

Tests

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))

Recursive solution (fails for 7, 13, and 14), 38 bytes

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.

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`) }
}

added 49 characters in body
Source Link
Justin Mariner
  • 5k
  • 1
  • 13
  • 18

JavaScript (ES6), 4747 43 bytes

-4 bytes thanks to @Arnauld

n=>eval('for(i=1;i=0;!/^9+0*$/.test(x=n*ii+=n);i++;);x';i')

Tests

let f=
n=>eval('for(i=1;i=0;!/^9+0*$/.test(x=n*ii+=n);i++;);x';i')

for(let i=1;i<=16;i++)console.log(`f(${i}) = `+f(i))

Recursive solution (fails for 7, 13, and 14), 4238 bytes

f=n=>g=(n,i=1i=0)=>/^9+0*$/.test(x=n*ii+=n)?xi:fg(n,i+1i)

Called like f(5)(). Reaches the max call stack size in Chrome and Firefox for n=7, n=13, and n=14.

f=
n=>g=(n,i=1i=0)=>/^9+0*$/.test(x=n*ii+=n)?xi:fg(n,i+1i)

for(let i=1;i<=16;i++){
    try { console.log(`f(${i}) = `+f(i)()) }
    catch(e) { console.log(`f(${i}) = FAILED`) }
}

JavaScript (ES6), 47 bytes

n=>eval('for(i=1;!/^9+0*$/.test(x=n*i);i++);x')

Tests

let f=
n=>eval('for(i=1;!/^9+0*$/.test(x=n*i);i++);x')

for(let i=1;i<=16;i++)console.log(`f(${i}) = `+f(i))

Recursive solution (fails for 7, 13, and 14), 42 bytes

f=(n,i=1)=>/^9+0*$/.test(x=n*i)?x:f(n,i+1)

Reaches the max call stack size in Chrome and Firefox for n=7, n=13, and n=14.

f=(n,i=1)=>/^9+0*$/.test(x=n*i)?x:f(n,i+1)

for(let i=1;i<=16;i++){
    try { console.log(`f(${i}) = `+f(i)) }
    catch(e) { console.log(`f(${i}) = FAILED`) }
}

JavaScript (ES6), 47 43 bytes

-4 bytes thanks to @Arnauld

n=>eval('for(i=0;!/^9+0*$/.test(i+=n););i')

Tests

let f=
n=>eval('for(i=0;!/^9+0*$/.test(i+=n););i')

for(let i=1;i<=16;i++)console.log(`f(${i}) = `+f(i))

Recursive solution (fails for 7, 13, and 14), 38 bytes

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.

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`) }
}

Source Link
Justin Mariner
  • 5k
  • 1
  • 13
  • 18

JavaScript (ES6), 47 bytes

n=>eval('for(i=1;!/^9+0*$/.test(x=n*i);i++);x')

Tests

let f=
n=>eval('for(i=1;!/^9+0*$/.test(x=n*i);i++);x')

for(let i=1;i<=16;i++)console.log(`f(${i}) = `+f(i))

Recursive solution (fails for 7, 13, and 14), 42 bytes

f=(n,i=1)=>/^9+0*$/.test(x=n*i)?x:f(n,i+1)

Reaches the max call stack size in Chrome and Firefox for n=7, n=13, and n=14.

f=(n,i=1)=>/^9+0*$/.test(x=n*i)?x:f(n,i+1)

for(let i=1;i<=16;i++){
    try { console.log(`f(${i}) = `+f(i)) }
    catch(e) { console.log(`f(${i}) = FAILED`) }
}