Décio, Rick Lavoie has already developed code for the Frobenius test and posted it in the past on this board. It is available at http://cs-people.bu.edu/coldfury/frobenius.c The discussions that went on at the time are here http://gmplib.org/list-archives/gmp-devel/2003-May/subject.html Hope this helps... Jim