<p><span class="h-card" translate="no"><a href="https://mathstodon.xyz/@christianp" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>christianp</span></a></span> Isn't the solution simply <code>m = (sqrt(8*n+9)-3)/2</code>, and then ⌊m⌋ ones, followed by a single -1 if m is not an integer, and then filled with zeroes?</p>