# Every number between $a_1$ to $a_n$ squared has a pattern, could someone explain it?

I am assuming this has something to do with number theory. To the point: I made a python script that squared every number between 1 and $10^7$, then checked if it was smaller or equal to 100, then between 100 and 1000, then 1000 and 10000 etc.

For you python guys, this is probably the most badly coded script you will ever put your eyes on:

a=0
b=0
c=0
d=0
e=0
f=0
g=0
h=0
i=0
j=0
k=0
l=0
for i in range(1,10000000):
if pow(i, 2) <=100:a+=1
if pow(i, 2) <=1000:b+=1
if pow(i, 2) <=10000:c+=1
if pow(i, 2) <=100000:d+=1
if pow(i, 2) <=1000000:e+=1
if pow(i, 2) <=10000000:f+=1
if pow(i, 2) <=100000000:g+=1
if pow(i, 2) <=1000000000:h+=1
if pow(i, 2) <=10000000000:i+=1
if pow(i, 2) <=100000000000:j+=1
if pow(i, 2) <=1000000000000:k+=1
if pow(i, 2) <=10000000000000:l+=1
print (a)
print (b)
print (c)
print (d)
print (e)
print (f)
print (g)
print (h)
print (i)
print (j)
print (k)
print (l)
input()

This was the output of my program:

10
31
100
316
1000
3162
10000
31622
9999999 <-- Is this an anomaly, why?
316227
1000000
3162277

What I noticed is that the output numbers starting with 3, contains the digits of $\sqrt{10}$. Could anyone explain why this happens?

-
Please learn to use arrays, then the above code would have been 30 lines shorter I dont know python, but it should end up looking something like this: for j in range(2,13): for i in range(1,10000000): if pow(i, 2) <=10^j: a[j]+=1 print a[j] input – Arjang Feb 20 '13 at 13:51
You don't even need arrays, just a loop here, as you don't need to store it. for j in range (2,13): count=0; for i in range (1,pow(10,j): if pow(i,2)<10^j: count +=1; print count – Ross Millikan Feb 20 '13 at 14:41

If $n^2\le a$, then $n\le\sqrt a$. That value of b for example is $\sqrt{1000}=10\sqrt{10}$ rounded down.