@IEATPYTHON/

Prime Numbers to the nth term

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
def prime(x):
	for i in range(2, x-1):
		if x % i == 0:
			return False
	return True
cluster = []
for num in range(2, int(input('Limit:'))):
	if prime(num):
		if len(str(cluster)) >= 75:
			print(cluster)
			cluster = []
		cluster.append(num)
if len(str(cluster)) < 75:
	print(cluster)
input('\nAll primes found! Press enter to exit.')
exit()