Hello, I am making a console application for a window home computer. The application will search for factors of a number that the user enters. Everything works fine up to about [10^10 = 10000000000]. I am unsure if C++ has a maxium number allowence. If this is the case can you please tell me. Otherwise here is the code I made:
#include <iostream>
#include <sstream>
#include <cmath>
using namespace std;
int main(){
bool Running = true;
cout << "*****************" << endl;
cout << "* FACTOR FINDER *" << endl;
cout << "*****************" << endl;
cout << "MADE BY MICHAEL HARRISON" << endl;
cout << "\n";
cout << "AFTER ENTERING A NUMBER PRESS THE RETURN KEY TO FIND ITS FACTORS" << endl;
long double Check_Number = 0;
long double The_Number = 0;
cin >> The_Number;
long double sqrt_The_Number = int(sqrt(The_Number))+1;
long int i = 2;
long int Total_Factors = 0;
cout.setf(ios::fixed);
cout.precision(0);
while (i < sqrt_The_Number){
Check_Number = The_Number/i;
if (Check_Number == int (Check_Number)){
cout << Check_Number << " * " << i << endl;
++Total_Factors;
}
++i;
}
if (Total_Factors == 0){
cout << "THIS NUMBER IS PRIME";
}else{
if (sqrt(The_Number) == int(sqrt(The_Number))){
cout << "TOTAL NUMBER OF FACTORS: " << Total_Factors * 2 - 1;
}else{
cout << "TOTAL NUMBER OF FACTORS: " << Total_Factors * 2;
}
}
cout << "\n" << "\n";
return 0;
cin.get();
}
It doesn't matter if this isn't thew most efficient way, I just want it to work. I would be very greatful if someone could answer this post. Thanks.