| 1 | initial version |
Perhaps, the easiest way is to use pari.ispower():
pari.ispower(Mod(n,q), b)
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.