

So, there are two ways to make six - 1 times 6, and 2 times 3. "2 times 3 equals 6, so 2 and 3 are factors of 6. (In ancient Greece, where the modern concept of infinity wasn't quite understood, Euclid described the quantity of prime numbers simply as "more than any assigned multitude of prime numbers.")Īnother way of understanding prime numbers and composites is to think of them as the product of factors, Zegarelli says. The Greek mathematician Euclid, back in circa 300 B.C.E., devised a Proof of the Infinitude of Primes, which may have been the first mathematical proof showing that there is an infinite number of prime numbers. There are plenty of other prime numbers - 2, 3, 7 and 11 also are on the list, and it keeps rolling from there. But the easier way to say that is to call it a prime number." So, you could call 5 a non-rectangular number. "The best you can do it is string it into a line, a single row of five coins. "But if you take the number 5, no matter how you try, you can't put it into a rectangle," Zegarelli notes. With the number 12, you could make it into more than one type of rectangle - you could have two rows of six coins, or three times four." You can do that with eight, too, by putting four coins into two rows.

You could form them into a rectangle, with two rows of three coins. This should solve both your problems."Think about the number 6," says Zegarelli, citing a composite number. Now what is happening is, for every instance of a prime number x (the prime number) is being added (appended) to the list primeNums. Again, using the if statement from before: #defining the list To create a list of prime numbers, you must first define a list, and then add the prime numbers to that list. What this does now, is for every instance of a prime number, you will add 1 to the count of prime numbers. Thus what is happening, when you use 100 as your num your function will return 1060, as this is the sum of all the primes up to 100.įirst, if you want to know the total amount of prime numbers up to a certain number, you can use the following: #define a variable to track the total number of primes The problem lies within this: if sympy.isprime(x) = True:Ībove, when you are doing primes = primes + x what you are saying is that you want to add the value of the x (a prime number) to the variable primes.
