Or you could write modular exponentiation like this.

   powmod =: 3 :('''m a p''=.y';'b=.|.#:p';'t=.m&|@:*';'t/ b # t~^:(<#b) a')
   powmod 2147483647 16807 2147483646
1

Here, powmod m,a,p computes m|a^p precisely.

Ambrus
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to