Modulo and Big Number

Hello Everybody!

Here is my code:

1
2
3
4
5
6
7
8
#include <iostream>
using namespace std;
void main()
{
	long long unsigned a=456787766311376,c=0;
	c=a*a;
	cout<<c%3610894530248221;
}


When I build it, it show me: 3322096072623696, which is wrong, because GP Pari shows different: 36522171218096.
What I need to do, to get same results as PARI gives to me?
Tnx :)

Btw. I'm working in VisualStudio2010
Last edited on
What's PARI? I suspect you have overflow.
I think long long is generally only 64 bits, and can hold up to about 10^19 (20 in case of unsigned). So you probably have integer overflow. You could look into large number library, or just try to do the math yourself.
You'd need 98 bits to hold the result of a*a. long long is 64 bits in VC++10.
Topic archived. No new replies allowed.