I wanted to make a small consoleapp on C# that organizes prime numbers into an array and prints them out.
My only problem is actually: how do I mathematically and programmatically recognize a prime number to put in that array and then move onto the next number?
A prime number cannot be evenly divided like 2, 3, 5, 7, 11, 13, 17, …
So you divide with numbers like 2, 3, and 5, maybe a few others with the modulus operator. If the result is not zero than its prime. ( general answer possibly not complete.)
a number is prime if it is not divisible by any other number (simple check: n is prime if all numbers below the square root of n (rounded up) don’t evenly divide it)
Multiples of 2, 3, and 5 cover most numbers. Just the way it is. I take it you haven’t done mush algebra, but that’s ok. the first link gave you many ways to check for primes.
As an exercise start counting and see if the number is evenly divisible by another number. 2 & 3 are prime.
4 is divisible by 2
5 is prime
6 is divisible by 2 and 3
7 is prime
8 is divisible by 2, 8 = 2 x 4, 4 = 2 x 2, so 8 = 2 x 2 x 2 (this is 8 factored. Factoring is the smallest possible numbers multiplied together to make a larger number. In this case 8)