Program for finding primes/ common denominators

Hey i need help streamlining a program and generally improving my coding vocabulary. i made a program that calculates whether or not a number is prime, and if several numbers have a common denominator. The problem i'm running into however is that the program can't calculating primes over 15,485,863. For instance if i put 15,485,867 into my program it will return that it's divisible by 3, and 5 and then the process will terminate and i won't get the option to continue running the program. Is this cause by using INT data types for my variables? is the excess data somehow spilling over into other parts? i don't quit understand why it would do that, but if the computer received a value for the number it couldn't handle i feel that would cause the program to terminate. also are there any other methods i can try to make this code more simple?


#include <iostream>

using namespace std;

int main()
{
int x, a, b, c, A, B, C, number;
int cont;
for (cont = 1; cont == 1; cont+=0) {
cout<< "enter how many numbers you would like to use up to 3." << endl;
cin>> number;
if (number == 1){

cout<<"enter the integer you would like to use"<<endl;
cin >> a;
for (x = 1;x<a; x++){
A=a%x;
if(A == 0){
cout<< x <<endl;
}
}
}
else if(number == 2){
cout<< "enter both integers you would like to use." <<endl;
cin>> a;
cin>> b;
if(b>=a){
for (x = 1;x<a; x++){
A=a%x;
B=b%x;
if(A+B == 0){
cout<< x <<endl;
}
}
}
else {
for (x = 1;x<b; x++){
A=a%x;
B=b%x;
if(A+B == 0){
cout<< x <<endl;
}
}
}
}
else{
cout<< "enter the three integers you would like to use." <<endl;
cin>> a;
cin>> b;
cin>> c;
if(a<=b & a<=c){
for (x = 2;x<a; x++){
A=a%x;
B=b%x;
C=c%x;
if(A+B+C == 0){
cout<< x <<endl;
}
}
}
else if(b<=c) {
for (x = 2;x<b; x++){
A=a%x;
B=b%x;
C=c%x;
if(A+B+C == 0){
cout<< x <<endl;
}
}
}
else {
for (x = 2;x<c; x++){
A=a%x;
B=b%x;
C=c%x;
if(A+B+C == 0){
cout<< x <<endl;
}
}
}


}
cout<< "would you like to continue? 0 for no 1 for yes"<<endl;
cin>>cont;

}
return 0;
}
Topic archived. No new replies allowed.