Add gcd(a,b) and powermod(a,b,m).
This commit is contained in:
parent
2ccca36502
commit
4cd7e62ce4
@ -174,6 +174,24 @@ public class Functions {
|
||||
return fact.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Take (a^b) mod m.
|
||||
* @param a Number
|
||||
* @param b Exponent
|
||||
* @param m Modulus
|
||||
* @return pow(a,b)%m.
|
||||
*/
|
||||
public double powermod(double a, double b, double m) {
|
||||
return (pow(a, b) % m + m) % m;
|
||||
}
|
||||
|
||||
public int gcd(int a, int b) {
|
||||
if (b == 0) {
|
||||
return a;
|
||||
}
|
||||
return gcd(b, a % b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Differentiate the function with respect to idv.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user