function egcd(a,b){
c = a % b;
if(c == 0){
return [b,0,1];
}
var arreglo= egcd(b,c);
return [arreglo[0], arreglo[2], (Math.floor(arreglo[1]-(arreglo[2]*Math.floor(a/b))))];
}
function gcd(a,b){
if((a%b) == 0){
return b;
}
return gcd(b, (a%b));
}
function inversa(e, n){
var eg = egcd(e, n);
alert(eg[0]);
alert(eg[1]);
alert(eg[2]);
if(eg[0]== 1){
return ((eg[1]+n) % n);
}else{
return null;
}
}
function potmod(x, pot, mod) {
var bits = pot;
var res = 1;
var temp = x;
while (bits > 0) {
if (bits % 2 == 1) {
res = (res * temp) % mod;
}
temp = (temp * temp) % mod;
bits = bits >> 1;
}
return res;
}
function prime(n){
if(n <= 1){
return false;
}
if((n%2) == 0){
if (n == 2 ){
return true;
}else{
return false;
}
}
var i = 3;
while (i <= Math.sqrt(n)){
if((n%i) == 0){
return false;
}
i += 2;
};
return true;
}
function randint(min, max){
return Math.floor(Math.random() * (max - min)) + min;
}
function rprime(digitos){
minimo = Math.pow(10,(digitos-1));
maximo = minimo * (10-1);
while(true){
var r = randint(minimo, maximo);
if(prime(r)){
return r;
};
};
}
function pickone(mod){
return randint(2,mod-1);
}
/*window.onload = function(){
alert(prime(7));
}*/