Lattice Points in a Circle
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
0 <= r <= 50
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Math problems
- Leap YearBeginner
- Matches in a TournamentBeginner
- Number of Common FactorsBeginner
- Power of FourBeginner
- Power of ThreeBeginner
- Power of TwoBeginner
- Product Minus Sum of DigitsBeginner
- Seconds to ClockBeginner