2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199
Chat with our AI personalities
Yes. All non-prime numbers are composite numbers, which simply means a number has one or more prime factors other than 1 and the number itself.
PRINT 2,3,5,7,11,13,17,19,23,29,31,37
Set builder notation for prime numbers would use a qualifying condition as follows. The set of all x's and y's that exist in Integers greater than 1, such that x/y is equal to x or 1.
int sum = 0; int i; for(i = 0; i < n; ++i) { sum += i; }
Loop through some numbers - for example, 2 through 100 - and check each one whether it is a prime number (write a second loop to test whether it is divisible by any number between 2 and the number minus 1). If, in this second loop, you find a factor that is greater than 1 and less than the number, it is not a prime, and you can print it out.