Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''Function L(r) counts number of lattice points inside a circle of radius r, where a lattice point is a point (m, n) with integer coordinates. L(r) converges to the area of a circle with radius r.'''
- def L(r):
- count = 0
- pairs = [0, 0]
- for i in range(-r, r + 1):
- pairs[0] = i
- for j in range(-r, r + 1):
- pairs[1] = j
- if ((pairs[0] ** 2) + (pairs[1] ** 2)) ** 0.5 <= r:
- count += 1
- return count
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement