To keep it simple:
Write a main loop that goes through all the numbers, starting with 2, and incrementing one at a time. Determine whether each number is a Prime number. If it is, increment a counter.
To determine whether each number is a prime number, either use an inner loop, or a separate function. Test divisibility of the number "n" by every number from 2 to n-1. If you find a factor, then it is not a prime number.
Note that you can test divisibility by using the "%" operator. For example:
if (number % factor == 0)
// number is divisible by factor
else
// it isn't
Chat with our AI personalities
6 2,3
The previous prime number is 23,456,787,559 and the next prime number is 23,456,787,593.
To find the prime factors of any number then divide the number by prime numbers of increasing value. When a prime number wholly divides the original number repeat the process with the same prime number but each time with the new quotient until complete division does not occur. Repeat with a prime number of higher value until the final quotient is 1. Using this process gives the prime factors of 374 as 2, 11 and 17.
Prime factorization is when you find all the prime factors of a number.
Find a prime number that is even. 2.