Sep-23-2017, 04:51 PM
import math prime_count = 0 #This Code checks if the n integer is prime! def is_prime(n): if n % 2 == 0 and n > 2: # 2 is the only even prime return False return all(n% i for i in range(3, int(math.sqrt(n)) + 1, 2)) print(is_prime(5)) import sys prime_count = 0 #prime counter for arg in sys.argv[1:]: #for all the arguments (typed) in the command n = int(arg) if (is_prime(n)): print('The Number ',n,' is Prime!') #Displays the prime number if True prime_count += n #prime_count = primecount + 1 print('Total Primes:', prime_count)I understand the whole code just there's this bit that I don't understand:
return all(n% i for i in range(3, int(math.sqrt(n)) + 1, 2))And it didn't work any other way it would start giving me 4 and 8 as prime numbers

Anyone care to explain?