FunctionRacerProblemsRace

Lattice Points in a Circle

BeginnerMathPython, JavaScript, TypeScript, Java, C++

A circle of radius r is centered at the origin. Return how many points with integer coordinates (x, y) lie inside the circle or exactly on it, that is x*x + y*y <= r*r.

Example 1

r 1
returns 5

(0,0), (1,0), (-1,0), (0,1), (0,-1).

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Math problems