T
Todd.Branchflower
Hey everyone,
I am new to c++ and the group and would appreciate your help.
I was doing a problem on projecteuler.net in which you had to find the
largest factor of an extremely large number. Unfortunately, I didn't
know how to accommodate a number of this size in c++. After
developing my algorithm and writing it in c++, I wrote the program in
ruby (a bit easier for large numbers) and found the answer. Looking
in the forum at other people's code, I was able to change mine to
work:
#include <iostream>
#include <cmath>
using namespace std;
int main() {
long long N=317584931803LL;
for (long long int i=2; i<=sqrt(N); i++) if (!(N%i)) N/=i;
cout << N;
string wait;
cin >> wait;
return 0;
}
My question is, what is the significance of the LL convention
following the number?? Why won't the code work without it? Also,
some people didn't need the LL when they declared N as __int64. This
doesn't work on my compiler (Dev-C++), as the compiler says the number
is too large for the __int64 data type. Why? Final question, how can
I compile programs at the command line with Dev-C++?
Thanks in advance for your help,
Todd
I am new to c++ and the group and would appreciate your help.
I was doing a problem on projecteuler.net in which you had to find the
largest factor of an extremely large number. Unfortunately, I didn't
know how to accommodate a number of this size in c++. After
developing my algorithm and writing it in c++, I wrote the program in
ruby (a bit easier for large numbers) and found the answer. Looking
in the forum at other people's code, I was able to change mine to
work:
#include <iostream>
#include <cmath>
using namespace std;
int main() {
long long N=317584931803LL;
for (long long int i=2; i<=sqrt(N); i++) if (!(N%i)) N/=i;
cout << N;
string wait;
cin >> wait;
return 0;
}
My question is, what is the significance of the LL convention
following the number?? Why won't the code work without it? Also,
some people didn't need the LL when they declared N as __int64. This
doesn't work on my compiler (Dev-C++), as the compiler says the number
is too large for the __int64 data type. Why? Final question, how can
I compile programs at the command line with Dev-C++?
Thanks in advance for your help,
Todd