I follow discussions on the Algorithms community on orkut. Came across one question which asked us to implement very big integers in C/C++. We can calculate 12! using integer data type, 20! using long long. Java provides a data type BigInteger which can handle it, Python :) can handle REALLY LARGE VALUES. In C/C++ we can implement this with the help of an integer array where each digit is represented as an element of the array. I have used a class for this purpose.
class large
{
int no[SIZE];
public:
large operator +(large& x);
large operator *(large& x);
large (string _no);
large ();
void print();
};
syntax highlighted by Code2HTML, v. 0.9.1
I have attached the source code, one can have a look at it. The program could calculate the factorial of 300, which is 616 Characters long :).
Here's the source code. Download(right click and save)
Comments
Good work
Good work buddy, I see you are writing good code these days!
---
Sattvik
http://sattvik.info
Thanks Sattvik. :)
Thanks Sattvik. :)