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)

Source: codewars | Difficulty: EASY
Tags: Geometry

Fundamentals

Mathematics

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):
	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) ** 0.5 // 1 for 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
	for x in range(-n, 0):
		y = -n
		while x ** 2 + y ** 2 > n ** 2:
			ct -= 4
			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