Skip to main content
Commonmark migration
Source Link

#JavaScript (ES6), 66

JavaScript (ES6), 66

Recursive, input n as a string (not a number) and limiting the output string size to 2GB (that is above the string limit of most javascript engines)

f=(n,i=1e9,s='',l=n.length)=>s[n-1]?s:f(n,i+=l,s+(i+'').slice(-l))

Test

f=(n,i=1e9,s='',l=n.length)=>s[n-1]?s:f(n,i+=l,s+(i+'').slice(-l))

function test() {
  var v=I.value;
  Alert.textContent=v % v.length ?
    'Warning: input value is not divisible by its string length':'\n';
  Result.textContent=f(v);
}  

test()
<input type=number id=I value=105 oninput='test()' max=500000>
<pre id=Alert></pre>
<pre id=Result></pre>

#JavaScript (ES6), 66

Recursive, input n as a string (not a number) and limiting the output string size to 2GB (that is above the string limit of most javascript engines)

f=(n,i=1e9,s='',l=n.length)=>s[n-1]?s:f(n,i+=l,s+(i+'').slice(-l))

Test

f=(n,i=1e9,s='',l=n.length)=>s[n-1]?s:f(n,i+=l,s+(i+'').slice(-l))

function test() {
  var v=I.value;
  Alert.textContent=v % v.length ?
    'Warning: input value is not divisible by its string length':'\n';
  Result.textContent=f(v);
}  

test()
<input type=number id=I value=105 oninput='test()' max=500000>
<pre id=Alert></pre>
<pre id=Result></pre>

JavaScript (ES6), 66

Recursive, input n as a string (not a number) and limiting the output string size to 2GB (that is above the string limit of most javascript engines)

f=(n,i=1e9,s='',l=n.length)=>s[n-1]?s:f(n,i+=l,s+(i+'').slice(-l))

Test

f=(n,i=1e9,s='',l=n.length)=>s[n-1]?s:f(n,i+=l,s+(i+'').slice(-l))

function test() {
  var v=I.value;
  Alert.textContent=v % v.length ?
    'Warning: input value is not divisible by its string length':'\n';
  Result.textContent=f(v);
}  

test()
<input type=number id=I value=105 oninput='test()' max=500000>
<pre id=Alert></pre>
<pre id=Result></pre>

deleted 1 character in body
Source Link
edc65
  • 32.2k
  • 3
  • 36
  • 90

#JavaScript (ES6), 66

Recursive, input n as a string (not a number) and limiting the output string size to 2GB (that is above the string limit of most javascript engines)

f=(n,i=1e9,s='',l=n.length))=>s[n-1]?s:f(n,i+=l,s+(i+'').slice(-l))

Test

f=(n,i=1e9,s='',l=n.length)=>s[n-1]?s:f(n,i+=l,s+(i+'').slice(-l))

function test() {
  var v=I.value;
  Alert.textContent=v % v.length ?
    'Warning: input value is not divisible by its string length':'\n';
  Result.textContent=f(v);
}  

test()
<input type=number id=I value=105 oninput='test()' max=500000>
<pre id=Alert></pre>
<pre id=Result></pre>

#JavaScript (ES6), 66

Recursive, input n as a string (not a number) and limiting the output string size to 2GB (that is above the string limit of most javascript engines)

f=(n,i=1e9,s='',l=n.length))=>s[n-1]?s:f(n,i+=l,s+(i+'').slice(-l))

Test

f=(n,i=1e9,s='',l=n.length)=>s[n-1]?s:f(n,i+=l,s+(i+'').slice(-l))

function test() {
  var v=I.value;
  Alert.textContent=v % v.length ?
    'Warning: input value is not divisible by its string length':'\n';
  Result.textContent=f(v);
}  

test()
<input type=number id=I value=105 oninput='test()' max=500000>
<pre id=Alert></pre>
<pre id=Result></pre>

#JavaScript (ES6), 66

Recursive, input n as a string (not a number) and limiting the output string size to 2GB (that is above the string limit of most javascript engines)

f=(n,i=1e9,s='',l=n.length)=>s[n-1]?s:f(n,i+=l,s+(i+'').slice(-l))

Test

f=(n,i=1e9,s='',l=n.length)=>s[n-1]?s:f(n,i+=l,s+(i+'').slice(-l))

function test() {
  var v=I.value;
  Alert.textContent=v % v.length ?
    'Warning: input value is not divisible by its string length':'\n';
  Result.textContent=f(v);
}  

test()
<input type=number id=I value=105 oninput='test()' max=500000>
<pre id=Alert></pre>
<pre id=Result></pre>

Source Link
edc65
  • 32.2k
  • 3
  • 36
  • 90

#JavaScript (ES6), 66

Recursive, input n as a string (not a number) and limiting the output string size to 2GB (that is above the string limit of most javascript engines)

f=(n,i=1e9,s='',l=n.length))=>s[n-1]?s:f(n,i+=l,s+(i+'').slice(-l))

Test

f=(n,i=1e9,s='',l=n.length)=>s[n-1]?s:f(n,i+=l,s+(i+'').slice(-l))

function test() {
  var v=I.value;
  Alert.textContent=v % v.length ?
    'Warning: input value is not divisible by its string length':'\n';
  Result.textContent=f(v);
}  

test()
<input type=number id=I value=105 oninput='test()' max=500000>
<pre id=Alert></pre>
<pre id=Result></pre>