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();
|
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.
|
* Differentiate the function with respect to idv.
|
||||||
*
|
*
|
||||||
@ -862,7 +880,7 @@ public class Functions {
|
|||||||
public void setLang(String l) {
|
public void setLang(String l) {
|
||||||
lang = l;
|
lang = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class finds permutations of an array.
|
* This class finds permutations of an array.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user