Function: math-pow-mod-step

math-pow-mod-step is a byte-compiled function defined in calc-arith.el.gz.

Signature

(math-pow-mod-step A N M)

Source Code

;; Defined in /usr/src/emacs/lisp/calc/calc-arith.el.gz
(defun math-pow-mod-step (a n m)   ; [I I I I]
  (math-working "pow" a)
  (let ((val (cond
	      ((eq n 0) 1)
	      ((eq n 1) a)
	      (t
	       (let ((rest (math-pow-mod-step
			    (math-imod (math-mul a a) m)
			    (math-div2 n)
			    m)))
		 (if (math-evenp n)
		     rest
		   (math-mod (math-mul a rest) m)))))))
    (math-working "pow" val)
    val))