Here is my code:
#include <iostream>
#include <ctype.h>
using namespace std;
class Project3
{
public:
long double divbythree()
{
while (i<halfprime){
primefactor = prime/i;
++i;
if (primefactor == (long long int)primefactor){
//if (modf(primeoverthree, 0) == 0){
cout << "Prime factor is: " << primefactor << endl;
cout << "Denominator is: " << i << endl;
}
else{/*empty else statement*/ }
}
cout << primefactor << endl;
return prime;
}
private:
long double primefactor = 1;
long double prime = 600851475143;
long double halfprime = 300425737570;
long double i = 1;
};
int main() {
Project3 Pro3;
Pro3.divbythree();
return 0;
}
...and here is my output:
Prime factor is: 6.00851e+11
Denominator is: 2
Prime factor is: 8.4627e+09
Denominator is: 72
Prime factor is: 7.16152e+08
Denominator is: 840
Etc.
Is there any way to change the IDE settings so that the console shows all elements of the double?
Or maybe so that output displays to some decimal place, i.e. to 5 decimal places.
Any help would be appreciated, thank you.
Edit: Answer here: How to 'cout' the correct number of decimal places of a double value?