8/18/2023 0 Comments Prime number list to 100 python![]() #print(n) #otherwise it prints out the number since it is a prime number #print(n) #if one of the factors is 2 it prints it because it is a prime number When you input a prime number it returns a blank array. If we run this and I input 10 it returns this : Print(n) #otherwise it prints out the number since it is a prime numberįor n in b: #iterates through the list of factors and checks if they are prime If n % 2 = 0 or n <= 1: # if it is less than one or is a factor of 2 it returns false and does nothingįor divisor in range(3, sqr, 2): #checks for other divisors ![]() Print(n) #if one of the factors is 2 it prints it because it is a prime number Instead of printing it you could also append it to another list by replace the print(n) with something else. Here you can print the list of factors and then iterate through the list of factors and this program will print out the ones that are prime.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |