Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,895 questions

51,826 answers

573 users

How to generate a list of prime number between specific range in Python

1 Answer

0 votes
def getPrimeList(x, y):
    prime_list = []
    for n in range(x, y):
        isPrime = True
 
        for i in range(2, n):
            if n % i == 0:
                isPrime = False
                 
        if isPrime:
            prime_list.append(n)
             
    return prime_list
 
prime_list = getPrimeList(30, 120)

print(prime_list)




'''
run:

[31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113]

'''

 



answered Apr 29, 2021 by avibootz

Related questions

...