Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
12
Task/Repeat-a-string/JavaScript/repeat-a-string-3.js
Normal file
12
Task/Repeat-a-string/JavaScript/repeat-a-string-3.js
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
function nreps(s, n) {
|
||||
var o = '';
|
||||
if (n < 1) return o;
|
||||
while (n > 1) {
|
||||
if (n & 1) o += s;
|
||||
n >>= 1;
|
||||
s += s;
|
||||
}
|
||||
return o + s;
|
||||
}
|
||||
|
||||
nreps('ha', 50000);
|
||||
Loading…
Add table
Add a link
Reference in a new issue