Questions tagged [bigmod]

4 questions
1
vote
0 answers

Is SOD(A^b) % mod == SOD(bigmod(A,b,mod))?

I have to calculate A^b where A^b can be a huge number then find The SOD(Sum of divisors) of that number. So, If I calculate SOD(bigmod(A,b,mod)) will this return the same value as SOD(A^b) % mod Asking for this As I am getting WA and could not get…
sabertooth
  • 582
  • 1
  • 7
  • 23
0
votes
1 answer

bigmod function returns negative value

long long int big_mod(long long int base, long long int power, long long int mod) { if(power==0) return 1; else if(power%2==1) { int p1 = base % mod; int p2 = (big_mod(base,power-1,mod))%mod; return…
0
votes
0 answers

How to solve bigmod where range of n,p,m where (n,p,m)<=10^18

I can solve bigmod if range of m is <=10^9. But if range more than this range my procedure overflows. How can i solve (n^p)%m where (n,m,p)<=10^18
a_rahman
  • 21
  • 3
-4
votes
1 answer

How can I determine the value of 4^(4^(10^9))%9^9 in C++14?

I've tried big mod algorithm successfully with numbers like 9^(10^9). But when the power is also too much big to use, how to get the final answer? #include #include #define ULL unsigned long long using namespace std; ULL mod(ULL…
Samnan Rahee
  • 31
  • 1
  • 7