javascript - Fermat's little theorem in JS -


I just tried to apply the minor theorem of fermat in javascript. I tried it in both ways, a ^ (p-1) mod p = 1 and a ^ p mod p = a modern p.

  function formatted (A, P) {return (((a ^ (p -1))% p) ​​=== 1); }  

and

  function formatted (A, P) {return (a ^ p)% p) ​​=== (one% p); }  

It does not work in both ways, is there any way to fix it?

javascript ^ Math.pow (x, y) for you.

  function formatted (a, p) {return Math.pow (a, p - 1)% p is required === 1; }  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -