countLatticePoints
// Count integer-coordinate points in radius-r circle
public static int countLatticePoints(int r) {
int count = 0;
int y = 0;
for(int x = r; x > 0; x--) {
while(x*x + y*y < r*r) y++;
count += y;
}
return 4 * count + 1;
}