Advertisement
Guest User

Untitled

a guest
Sep 25th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. '''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.'''
  2.  
  3. def L(r):
  4. count = 0
  5. pairs = [0, 0]
  6. for i in range(-r, r + 1):
  7. pairs[0] = i
  8. for j in range(-r, r + 1):
  9. pairs[1] = j
  10. if ((pairs[0] ** 2) + (pairs[1] ** 2)) ** 0.5 <= r:
  11. count += 1
  12. return count
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement