Integral points on a circle Given radius $r$ which is an integer and center $(0,0)$, find the number of integral points on the circumference of the circle.

Let $$R^2= a^2 +b^2$$   
Then the Number of integral points is the number of integral solutions for $(a,b)$   
For example if $R=5$
Then $$(a,b)=(0,±5) ,(±5,0), (±3,±4)  $$ 
Hence number of points are 8.  
A Simple Algorithm for this is:   
for(i=0,i<=R;i++)   
{   
    for(j=0;j<=R;j++)
    {
        if(R*R==i*i+j*j)
         count++;
    }
}

This has 10^12 computations if R=10^6
Rather than this an Optimised approach is:
for(i=0,i<=R;i++)
{   
    if(sqrt(R*R-i*i) is an integer)
     count++;   
}

This has 10^6 computations if R=10^6 which takes only 0.1 seconds on an ordinary machine. 
You can check this link for checking if a float is an integer.   
