Created
December 7, 2022 15:44
-
-
Save aburousan/2e3c0563a2ba2858a09cea4d932b727d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import floor, sqrt | |
def lattice_inside(N):#give square of the radius,i.e., R = \sqrt(N) | |
summ = 0; | |
loop_no = int(N/3) + 2 | |
for i in range(0,loop_no+1): | |
a = floor(N/(3*i+1)) | |
b = floor(N/(3*i+2)) | |
# print(a,b,i) | |
summ = summ + 6*(a-b) | |
return summ + 1 | |
def lattice_on(N): | |
return lattice_inside(N)-lattice_inside(N-1) | |
print(lattice_on(7)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment