Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Here is a picture of "square numbers" from mathworld website.

A plot of the first few square numbers represented as a sequence of binary bits is shown above. The top portion shows $1^2$ to $255^2$, and the bottom shows the next 510 values. (Black is for "one" bit, and while is for "zero" bit)

I want to learn more about this pattern. However, there is no further explanation about the pattern of this plot from the website.

Is there any known result about this pattern ?

share|improve this question
Counting from the bottom from $0$, row $0$ has period two, and row $n$ when $n>0$ has period which is a divisor of $2^n$. –  Thomas Andrews Apr 3 '13 at 14:30
It's also the case that row $n$ values are symmetric around the multiples of $2^n$ - that is, the squares of $a2^n-b$ and $a2^n+b$ have the same $n$th bit, for all $a,b$ with $b<a2^n$ –  Thomas Andrews Apr 3 '13 at 14:35
Vertical periodicity: $(2^mn)^2=2^{2m}n^2=n^2<<2m,$ where $a<<b$ is a shifted to the left by b binary places (i.e. the pattern is shifted upwards). –  Loki Clock Apr 3 '13 at 14:37
I deleted my previous comment; the lengths of the rows of most significant digits are not powers of 2. –  Loki Clock Apr 3 '13 at 20:26
Has anyone tried this for other radixes? –  Jack M Apr 3 '13 at 21:22

2 Answers 2

This gives the lengths of the highest black lines:


share|improve this answer

Note that each line is periodic. The bottom line alternates white and black, as even and odd numbers have even and odd squares. The next line is the leading bit of the numbers $\pmod 4$. As the squares $\pmod 4$ go $0,1,0,1$ it will always be white. The squares $\pmod {16}$ go $0,1,4,9,0,1,4,9,0,1,4,9,0,1,4,9$ so the next line up will go white, white, black, white and repeat. The next will be white, white, white, black. You can continue .

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.