Given a positive integer, for example
4538, express it in binary with no leading
4538 base 10 = 1000110111010 base 2
Remove any trailing
Replace any runs of one or more
0's with a single
Evaluate the resulting complex expression and output the simplified Gaussian integer:
i+ii+iii+i = i+i*i+i*i*i+i = 2i+i^2+i^3 = 2i+(-1)+(-i) = -1+i
The output can be expressed in a traditional mathematical way, or given as two separate integers for the real and complex parts. For the
4538 example, any of these would be fine:
-1+i i-1 -1+1i (-1, 1) -1 1 -1\n1
For inputs like
29, mathy formatted outputs such as
0+0i are all fine.
j (or something else) instead of
i is fine if that is more natural for your language.
The shortest code in bytes wins.