python program to find first n prime numbers

Solutions on MaxInterview for python program to find first n prime numbers by the best coders in the world

showing results for - "python program to find first n prime numbers"
Adrián
07 Jul 2016
1n = int(input("Enter a number : "))
2c = 2
3while n!=0:
4  for i in range(2,c):
5    if c%i==0:
6      break
7  else:  
8    print(c,end=" ")  
9    n-=1
10  c+=1  
Lou
12 Aug 2018
1>>> def getprimes(x):	primes = []	# Loop through 9999 possible prime numbers	for a in range(1, 10000):		# Loop through every number it could divide by		for b in range(2, a):			# Does b divide evenly into a ?			if a % b == 0:				break		# Loop exited without breaking ? (It is prime)		else:			# Add the prime number to our list			primes.append(a)		# We have enough to stop ?		if len(primes) == x:			return primes		>>> getprimes(5)[1, 2, 3, 5, 7]>>> getprimes(7)[1, 2, 3, 5, 7, 11, 13]
queries leading to this page
python function to print first n prime numberspython program to get first ten prime numberspython prime numbers until 3d 20most efficient method to find first n prime numbersprogram to find first n prime numberspython program to find first n prime numbersget first n primes c 2b 2bhow to find first n prime numbers in pythonpython program for first n prime numbersalgorithm for printing n prime numbersfirst n prime number finder in pythonto find first n prime number in pythonget list of first 100 prime numebrs in arrya python premadeprint first n prime numbers in python if given n is input to write a python program for first n prime numbersprint first 10 prime numbers in pythonpython get first n prime numbersfind first n prime numbershow to make program that print first 10 prime numbers pythonfirst n prime numbers python codefirst n prime numbers pythonfind first n prime numbers pythonpython program first n prime numberswrite a python program to find the first prime number in the given range of m to n find first 10 prime numbers in pythonhow to get first n prime numbers in pythonprint first n prime numbersprint first n prime numbers in pythonprogram for first n prime numbers in pythonpython first n primeshow to find first n prime numbers in python using functionprint first 5 prime numbers in pythonprint first 10 prime numbers pythonfirst n prime numbers function using pythonwrite a python program for first n prime numbers write a program in pythn to print n prime numbers using while loop starting from 0 2c and take the input of x from the userprinting the first 5 primes in pythonpython print first n prime numbersprime numbers from 1 to n in pythonprint all prime numbers before a numbern prime numbers in pythonpython list prime numbers behind nto write a python program first n prime numbers first n prime numbers using pythonpython program to find first n prime numbers