list of prime numbers in python with list comprehension

Solutions on MaxInterview for list of prime numbers in python with list comprehension by the best coders in the world

showing results for - "list of prime numbers in python with list comprehension"
Oskar
27 Nov 2020
1n = 20
2
3primes = [i for i in range(2, n + 1) if all(i%j != 0 for j in range(2, int(i ** 0.5) + 1))]
4
5print(primes)