Skip to main content
added 547 characters in body
Source Link
tsh
  • 35.5k
  • 2
  • 34
  • 129

JavaScript (Node.js), 63 bytes

f=(n,m=2,i=0,p=n-i**m)=>p<0?f(n,m+1):!p||i&&f(p)<m?m:f(n,m,i+1)

Try it online!

Time out for not so large n as its terrible recursion design. It could be fast if we apply memorize to it (70 bytes).

f=(n,m=2,i=0,p=n-i**m)=>f[n]??=p<0?f(n,m+1):!p||i&&f(p)<m?m:f(n,m,i+1)
for (i = 0; i < 1000; i+= 20) {
  o.value +== [...Array(2050000)].map((_, ji) => (f(i + j).filter(v +=> '').padStartf(2v) > 5).join('') +', '\n';
}')
<output id=o<a style=white-spacehref="https:pre><//oeis.org/A111151">A111151</a>: <output id=o></output>

JavaScript (Node.js), 63 bytes

f=(n,m=2,i=0,p=n-i**m)=>p<0?f(n,m+1):!p||i&&f(p)<m?m:f(n,m,i+1)

Try it online!

Time out for not so large n as its terrible recursion design. It could be fast if we apply memorize to it (70 bytes).

f=(n,m=2,i=0,p=n-i**m)=>f[n]??=p<0?f(n,m+1):!p||i&&f(p)<m?m:f(n,m,i+1)
for (i = 0; i < 1000; i+= 20) {
  o.value += [...Array(20)].map((_, j) => (f(i + j) + '').padStart(2)).join('') + '\n';
}
<output id=o style=white-space:pre></output>

JavaScript (Node.js), 63 bytes

f=(n,m=2,i=0,p=n-i**m)=>p<0?f(n,m+1):!p||i&&f(p)<m?m:f(n,m,i+1)

Try it online!

Time out for not so large n as its terrible recursion design. It could be fast if we apply memorize to it (70 bytes).

f=(n,m=2,i=0,p=n-i**m)=>f[n]??=p<0?f(n,m+1):!p||i&&f(p)<m?m:f(n,m,i+1)

o.value = [...Array(50000)].map((_, i) => i).filter(v => f(v) > 5).join(', ')
<a href="https://oeis.org/A111151">A111151</a>: <output id=o></output>

added 547 characters in body
Source Link
tsh
  • 35.5k
  • 2
  • 34
  • 129

JavaScript (Node.js), 63 bytes

f=(n,m=2,i=0,p=n-i**m)=>p<0?f(n,m+1):!p||i&&f(p)<m?m:f(n,m,i+1)

Try it online!

Time out for not so large n as its terrible recursion design. It could be fast if we apply memorize to it (70 bytes).

f=(n,m=2,i=0,p=n-i**m)=>f[n]??=p<0?f(n,m+1):!p||i&&f(p)<m?m:f(n,m,i+1)
for (i = 0; i < 1000; i+= 20) {
  o.value += [...Array(20)].map((_, j) => (f(i + j) + '').padStart(2)).join('') + '\n';
}
<output id=o style=white-space:pre></output>

JavaScript (Node.js), 63 bytes

f=(n,m=2,i=0,p=n-i**m)=>p<0?f(n,m+1):!p||i&&f(p)<m?m:f(n,m,i+1)

Try it online!

JavaScript (Node.js), 63 bytes

f=(n,m=2,i=0,p=n-i**m)=>p<0?f(n,m+1):!p||i&&f(p)<m?m:f(n,m,i+1)

Try it online!

Time out for not so large n as its terrible recursion design. It could be fast if we apply memorize to it (70 bytes).

f=(n,m=2,i=0,p=n-i**m)=>f[n]??=p<0?f(n,m+1):!p||i&&f(p)<m?m:f(n,m,i+1)
for (i = 0; i < 1000; i+= 20) {
  o.value += [...Array(20)].map((_, j) => (f(i + j) + '').padStart(2)).join('') + '\n';
}
<output id=o style=white-space:pre></output>

Source Link
tsh
  • 35.5k
  • 2
  • 34
  • 129

JavaScript (Node.js), 63 bytes

f=(n,m=2,i=0,p=n-i**m)=>p<0?f(n,m+1):!p||i&&f(p)<m?m:f(n,m,i+1)

Try it online!