document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. /**
  2.  *
  3.  * @author Joel Fernandez
  4.    @web: CodeBotic.blogspot.com
  5.    @Fecha: 26706/2015
  6.    @Tema: Algoritmos sobre Maximo Comun Divisor de NĂºmeros Grandes
  7.  */
  8. public static int big_mcd(String nBig, int a)
  9.     {  
  10.         String tmpStr;
  11.         int tmpNum=0;
  12.        
  13.         int d;
  14.        
  15.         d=Integer.toString(a).length()+1;
  16.        
  17.         while(val(nBig,a)>=a)
  18.         {
  19.             if(nBig.length()>=d)
  20.             {
  21.                 tmpStr=nBig.substring(0, d);
  22.                 nBig=nBig.substring(d, nBig.length());
  23.             }
  24.             else
  25.             {
  26.                 tmpStr=nBig;
  27.                 nBig="";
  28.             }
  29.            
  30.                    
  31.             tmpNum=Integer.parseInt(tmpStr);
  32.             tmpNum=tmpNum%a;
  33.             tmpStr=Integer.toString(tmpNum);
  34.             nBig=tmpStr+nBig;
  35.         }
  36.         return tmpNum;
  37.     }
  38.     public static int val(String nBig, int a)
  39.     {  
  40.         if(nBig.length()>Integer.toString(a).length())
  41.             return a;
  42.         else
  43.             return Integer.parseInt(nBig);
  44.        
  45.     }
  46.     public static int mcd_euclides(int a,int b)
  47.     {
  48.         int r;
  49.         while(b!=0)
  50.         {
  51.             r=a%b;
  52.             a=b;
  53.             b=r;
  54.         }
  55.         return a;
  56.     }
');