You have the `radius` of a circle with the center in point `(0,0)`.

Write a function that calculates the number of points in the circle where `(x,y)` - the cartesian coordinates of the points - are `integers`.

Example: for `radius = 2` the result should be `13`.

`0 <= radius <= 1000`

![](http://i.imgur.com/1SMov3s.png)

Difficulty: introductory

Starter code:

def points(n):
	

Solutions:
def points(R):
    from math import sqrt
    point = sum(int(sqrt(R * R - x * x)) for x in range(0,R+1)) * 4 + 1
    return point

from math import floor, sqrt

def points(n):
    # solution is 
    # A000328       Number of points of norm <= n^2 in square lattice.
    # which can be calculated as 
    # a(n) = 4*A000603(n) - (4*n+3), n >= 0 where
    # A000603       Number of nonnegative solutions to x^2 + y^2 <= n^2
    # which can be calculated as 
    # a(n) = A001182(n) + 2*n + 1 where
    # A001182       Number of cells of square lattice of edge 1/n inside quadrant of unit circle centered at 0
    A001182 = sum(floor(sqrt(n**2-k**2)) for k in range(1,n))
    A000603 = A001182 + 2*n + 1
    A000328 = 4*A000603 - (4*n+3) 
    return A000328


def points(n):
    return 1 + 4 * sum(map(lambda x: int((n * n - x * x)**0.5),range(0,n+1)))

points=lambda n:1+4*sum((n*n-r*r)**.5//1for r in range(n))

import math

def points(n):
    if n == 0:
        return 1
    sum = 0
    for i in range(n):
        for j in range(1,n):
            if i*i+j*j <= n*n:
                sum+=1
    return 4*sum+5

def points(r):
    rr = r*r
    x = sum(int((rr - x*x) ** 0.5) for x in range(r))
    return x * 4 + 1

from math import sqrt
def points(n):
    return sum(int(sqrt(n ** 2 - i ** 2)) for i in range(n)) * 4 + 1

def points(n):
    n_2 = n ** 2 
    sq = [i ** 2 for i in range(1,n)]
    count = 0
    for i in sq:
        for j in sq:
            if i+j <= n_2:
                count=count + 1
    count =4 * (count + n) + 1
    return(count)

def points(n):
    ct = (2*n+1)**2 # num of pts in lattice intersecting B_n(0)
    
    for x in range(-n,0): # x coords in (- , -) quadrant
        y = -n # inital y in (- , -) quadrant
        while x**2 + y**2 > n**2: #while outside B_n(0)
            ct -= 4 # use quadrant symmetry -  if its not in the (- , -) quad of B_n(0) its not in any quad.
            y += 1
    return ct

def points(radius):
    cnt = radius * 4 + 1
    r2 = radius * radius
    for i in range(1, radius + 1):
        for j in range(1, radius + 1):
            if (i * i + j * j <= r2):
                cnt += 4
    return cnt