= (0+1) + (1+1) + (2+1) + (3+1) + ... + ((N-1)+1) + (N+1)
= (N +1)*N / 2
Number of characters copied if you construct a string of length N by concatenating a chunk of length 16 each time = (0+16) + (16+16) + (32+16) + ... + ((N-16)+16)
= 16*(0+1) + 16*(1+1) + 16*(2+1) + ...
= 16 * (N/16 +1)*(N/16) / 2
^^^^^^^^^^^^^^^
This is where the "technique" comes in: although the algorithm is still quadratic you're effectively moving a constant factor out the front. = M * (k+1)*k / 2 + k * (M+1)*M / 2
... which (rounding and integer constraints aside) is minimised for M = k, i.e. when the chunk size is the square root of the input length. Hence, for input length 256 we take chunk size 16.
Marginally related: on cs.CL the other day was "Punny Captions: Witty Wordplay in Image Descriptions"[0]. A mashup of these two projects would bring us that much closer to the dream of Social Media In A Box.
[0] https://arxiv.org/abs/1704.08224