Modular power in Golang  

> func power(x,y,p int64) int64 { var res int64 res = 1; // Initialize 
> result x =(x%p)%mod; // Update x if it is more than or // equal to p for 
> y>0{ // If y is odd, multiply x with result if y & 1==1{ res = 
> ((res*x)%p)%mod; } // y must be even now y = y/2; x = ((x*x)%p)%mod; } 
> return res; }
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to