I shall show you very simple example, very is calling factorial counting with recursion, but there is one detail which is very important, let’s look at my code , then I shall write what’s my problem.
#define PASSWORD_MAX 0x28
typedef unsigned long long longtype;
#include <iostream>
using namespace std;
longtype f(longtype n)
{
return (n <= 1) ? 1 : f(n - 1) * n;
};
void main(void)
{
for(longtype i = 0; i <= PASSWORD_MAX; i++)
{
if(f(i) != 0) cout << i << " -> " << f(i) << endl;
};
};
After this code, I got the next result: http://pastebin.com/ZHPtJBZ7
The max result, which is readable is: 22 -> 17196083355034583040
From 23 till end , as I understand, there are only numbers in “e” power, how can I print values from 23 fully, not in shorten format?
Thanks, Best Regards!
You are getting overflow. You should use libgmp.
Edit: Your code using GMP:
Result: