When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:
main {
max-width: 38rem;
padding: 2rem;
margin: auto;
}
class Prime: | |
def __init__(self): | |
self.found = [] | |
self.i = 2 | |
self.idx = -1 #Iterator用 | |
def __getitem__(self, n): #n番目の素数が見つかるまでwhileを回す | |
while len(self.found) < n+1: #すでに見つかっていれば定数時間ですむ | |
if not any(self.i % x == 0 for x in self.found): | |
self.found.append(self.i) |