Repeat a string: Difference between revisions

m
Line 716:
console.log("ha".repeat(5)); // hahahahaha</lang>
 
or, forFor larger numbers of repetitions, however, it proves significantly faster to progressively double a copy of the original string (concatenating it with itself), and appending the result to an accumulator wherever required for binary composition of the target number.
 
See the technique of 'Egyptian Multiplication' described in the Rhind Mathematical Papyrus at the British Museum.
9,659

edits