### Problem with large values

So i'm trying to divide large numbers into prime factors. My problem is that if the value is greater than 1*10^9 the program does nothing and just exit. Anyone know as to why this happens?

 ``123456789101112131415161718192021222324252627282930313233343536373839`` ``````#include using namespace std; long int Search = 1 ,a = 2,MaxPrime,prime, PrimeFactor; int main() { cout << "enter a number that you want divided into prim factors" << endl; cin >> MaxPrime; PrimeFactor = MaxPrime; while (a < PrimeFactor+1) { for (a; Search < a-1; Search++) { if (a % Search == 0 && Search != 1) { Search = 1; break; } } if (a % Search != 0 || a == 2) { prime = a; Search = 1; if(PrimeFactor % prime == 0 && prime != 0) { cout << prime << " is a primefactor in " << PrimeFactor << endl; PrimeFactor = PrimeFactor / prime; a = 1; } } a++; } system("pause"); return 0; }``````
A 32-bit signed integer can hold values from -2147483648 to +2147483647.
Sounds like you are exceeding the permitted range.
Topic archived. No new replies allowed.