我正在开发这个程序来确定一个数字是否是素数。编译时我没有收到任何错误,但输出不正确。谁能告诉我出了什么问题(以及如何解决?)?
#define PROMPT "Please enter a whole number: "
#define NOT_PRIME "The number is not a prime number! "
#define PRIME "The number is a prime number "
#define DONE 0
#define FIRST_FACTOR 3
using std::cout;
using std::cin;
int main(){
int i;
char number;
cout << PROMPT;
cin >> number;
for (i=FIRST_FACTOR; i<=number; i++){
prime = true;
for (int n=2; n<=i-1; n++){
if (i%n == 0){
prime = false;
}
}
if(prime){
cout << number << PRIME << endl;
}
else{
cout << number << NOT_PRIME << endl;
}
}
return 0;
}