1. ## primes

hello everyone.

the is a real pain in the neck...can anyone help me write a program that determines all the preimes from 1 to 1000 , counts them, and determine if any of the primes are carmuichael numbers...i donot know what the hell they are !!

HELP !!!!

i got this program from a friend but it only calculates the primes up to 100, how do i extend it to 1000 ??

#include <iostream.h>

void main(){
//declarations
int var1;
int var2;
int flag;
//tells that the user will see all the prime numbers up too 100
cout << "All of the prime numbers up to 100 are...\n";
//calculations

for(var1 = 2; var1 <= 100; var1++){
flag = 1;

for(var2 = 2; var2 < var1; var2++){

if((int)var1 % (int)var2 == 0){
flag = 0;
}
}
//output...

if(flag == 1){
cout << var2;
cout << " ";
}
}
cout << " ";
}

2. OK, here's some hints.

1). Is a Carmichael number prime?

2).>> i got this program from a friend but it only calculates the primes up to 100, how do i extend it to 1000 ??

for(var1 = 2; var1 <= 100; var1++)

3). Lastly, you don't need to check out all the values from 2 to var1, you only need to check up to the square root of var1.

You may also want to search this site. The question has been asked sooooooo many times before. Also search for the Sieve of Erasthones here and on the web.

3. http://primes.utm.edu/glossary/page....aelNumber.html

The Carmichael numbers under 100,000 are

561, 1105, 1729, 2465, 2821, 6601, 8911, 10585, 15841, 29341, 41041, 46657, 52633, 62745, 63973, and 75361.
Gonna be a dull answer upto 1000

Code:
```int main ( ) {
printf( "The Carmichael numbers under 1000 are: 561\n" );
return 0;
}```

4. Not exactly.

ALL primes are carmichael numbers. Those numbers are the rare composite carmichael numbers.

Erm sorry I wrote that wrong. All primes satisfy the test for carmichael numbers, but the distinction of carmicheal numbers is only applies to those composite numbers which also pass the test.

So, there are no prime carmicheal numbers under 1000, or under any maximum.