Horje
sieve of eratosthenes python Code Example
sieve of eratosthenes python
# sieve of eratosthenes 
def SieveOfEratosthenes(n):
    prime = [True for i in range(n + 1)]
    p = 2
    while (p * p <= n):
        if (prime[p] == True):
            for i in range(p * 2, n + 1, p):
                prime[i] = False
        p += 1
    prime[0] = False
    prime[1] = False
    r = []
    for p in range(n + 1):
        if prime[p]:
            r.append(p)
    return r

n = int(input("Get primes in range of?- "))
listOfPrime = SieveOfEratosthenes(n)
count = 1
# print primes 1-100 then 101-200 etc. in different line
for i in listOfPrime:
    if i > 100 * count:
        count += 1
        print()
    print(i, end = " ")




Python

Related
discord python webhook Code Example discord python webhook Code Example
print index Code Example print index Code Example
dataframe row print Code Example dataframe row print Code Example
get tensorflow version version in ubuntu Code Example get tensorflow version version in ubuntu Code Example
tensorflow_version Code Example tensorflow_version Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8