Power of power modulo with non square-free numbers
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
Reference https://www.hackerrank.com/challenges/devu-police/problem
I have five numbers a, b, c, d, N and I need to find $(a^b)^c^d$ mod N. N is non square-free number so euler totient theorem or CRT won't work here.
I have tried this way but according to test-cases my program gets timed out. I find $a^b$ mod N then I run power modulo with algorithm https://www.geeksforgeeks.org/modular-exponentiation-power-in-modular-arithmetic/ here exponent divided by 2 and I do with c so each computation needs O(d) which should not be rather logarithm solution expected.
Could you please help me to solve?
number-theory
 |Â
show 3 more comments
up vote
0
down vote
favorite
Reference https://www.hackerrank.com/challenges/devu-police/problem
I have five numbers a, b, c, d, N and I need to find $(a^b)^c^d$ mod N. N is non square-free number so euler totient theorem or CRT won't work here.
I have tried this way but according to test-cases my program gets timed out. I find $a^b$ mod N then I run power modulo with algorithm https://www.geeksforgeeks.org/modular-exponentiation-power-in-modular-arithmetic/ here exponent divided by 2 and I do with c so each computation needs O(d) which should not be rather logarithm solution expected.
Could you please help me to solve?
number-theory
Euler's totient theorem does not need a squarefree modulo, it is enough that the base is coprime to the modulo.
– Peter
Jul 28 at 11:45
This will be useful for your problem : en.wikipedia.org/wiki/Carmichael_function
– Peter
Jul 28 at 11:51
@Peter if they r not co-prime then what?
– Debasis Jana
Jul 28 at 12:08
If you know the factorization of $N$, my link should solve the problem.
– Peter
Jul 28 at 12:19
@Peter thank you ... :) actually I didn't go through your link .. ;)
– Debasis Jana
Jul 28 at 12:36
 |Â
show 3 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Reference https://www.hackerrank.com/challenges/devu-police/problem
I have five numbers a, b, c, d, N and I need to find $(a^b)^c^d$ mod N. N is non square-free number so euler totient theorem or CRT won't work here.
I have tried this way but according to test-cases my program gets timed out. I find $a^b$ mod N then I run power modulo with algorithm https://www.geeksforgeeks.org/modular-exponentiation-power-in-modular-arithmetic/ here exponent divided by 2 and I do with c so each computation needs O(d) which should not be rather logarithm solution expected.
Could you please help me to solve?
number-theory
Reference https://www.hackerrank.com/challenges/devu-police/problem
I have five numbers a, b, c, d, N and I need to find $(a^b)^c^d$ mod N. N is non square-free number so euler totient theorem or CRT won't work here.
I have tried this way but according to test-cases my program gets timed out. I find $a^b$ mod N then I run power modulo with algorithm https://www.geeksforgeeks.org/modular-exponentiation-power-in-modular-arithmetic/ here exponent divided by 2 and I do with c so each computation needs O(d) which should not be rather logarithm solution expected.
Could you please help me to solve?
number-theory
edited Jul 28 at 8:14
asked Jul 28 at 7:47
Debasis Jana
63
63
Euler's totient theorem does not need a squarefree modulo, it is enough that the base is coprime to the modulo.
– Peter
Jul 28 at 11:45
This will be useful for your problem : en.wikipedia.org/wiki/Carmichael_function
– Peter
Jul 28 at 11:51
@Peter if they r not co-prime then what?
– Debasis Jana
Jul 28 at 12:08
If you know the factorization of $N$, my link should solve the problem.
– Peter
Jul 28 at 12:19
@Peter thank you ... :) actually I didn't go through your link .. ;)
– Debasis Jana
Jul 28 at 12:36
 |Â
show 3 more comments
Euler's totient theorem does not need a squarefree modulo, it is enough that the base is coprime to the modulo.
– Peter
Jul 28 at 11:45
This will be useful for your problem : en.wikipedia.org/wiki/Carmichael_function
– Peter
Jul 28 at 11:51
@Peter if they r not co-prime then what?
– Debasis Jana
Jul 28 at 12:08
If you know the factorization of $N$, my link should solve the problem.
– Peter
Jul 28 at 12:19
@Peter thank you ... :) actually I didn't go through your link .. ;)
– Debasis Jana
Jul 28 at 12:36
Euler's totient theorem does not need a squarefree modulo, it is enough that the base is coprime to the modulo.
– Peter
Jul 28 at 11:45
Euler's totient theorem does not need a squarefree modulo, it is enough that the base is coprime to the modulo.
– Peter
Jul 28 at 11:45
This will be useful for your problem : en.wikipedia.org/wiki/Carmichael_function
– Peter
Jul 28 at 11:51
This will be useful for your problem : en.wikipedia.org/wiki/Carmichael_function
– Peter
Jul 28 at 11:51
@Peter if they r not co-prime then what?
– Debasis Jana
Jul 28 at 12:08
@Peter if they r not co-prime then what?
– Debasis Jana
Jul 28 at 12:08
If you know the factorization of $N$, my link should solve the problem.
– Peter
Jul 28 at 12:19
If you know the factorization of $N$, my link should solve the problem.
– Peter
Jul 28 at 12:19
@Peter thank you ... :) actually I didn't go through your link .. ;)
– Debasis Jana
Jul 28 at 12:36
@Peter thank you ... :) actually I didn't go through your link .. ;)
– Debasis Jana
Jul 28 at 12:36
 |Â
show 3 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2865076%2fpower-of-power-modulo-with-non-square-free-numbers%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Euler's totient theorem does not need a squarefree modulo, it is enough that the base is coprime to the modulo.
– Peter
Jul 28 at 11:45
This will be useful for your problem : en.wikipedia.org/wiki/Carmichael_function
– Peter
Jul 28 at 11:51
@Peter if they r not co-prime then what?
– Debasis Jana
Jul 28 at 12:08
If you know the factorization of $N$, my link should solve the problem.
– Peter
Jul 28 at 12:19
@Peter thank you ... :) actually I didn't go through your link .. ;)
– Debasis Jana
Jul 28 at 12:36