Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- * @author Joel Fernandez
- @web: CodeBotic.blogspot.com
- @Fecha: 26706/2015
- @Tema: Algoritmos sobre Maximo Comun Divisor de Números Grandes
- */
- public static int big_mcd(String nBig, int a)
- {
- String tmpStr;
- int tmpNum=0;
- int d;
- d=Integer.toString(a).length()+1;
- while(val(nBig,a)>=a)
- {
- if(nBig.length()>=d)
- {
- tmpStr=nBig.substring(0, d);
- nBig=nBig.substring(d, nBig.length());
- }
- else
- {
- tmpStr=nBig;
- nBig="";
- }
- tmpNum=Integer.parseInt(tmpStr);
- tmpNum=tmpNum%a;
- tmpStr=Integer.toString(tmpNum);
- nBig=tmpStr+nBig;
- }
- return tmpNum;
- }
- public static int val(String nBig, int a)
- {
- if(nBig.length()>Integer.toString(a).length())
- return a;
- else
- return Integer.parseInt(nBig);
- }
- public static int mcd_euclides(int a,int b)
- {
- int r;
- while(b!=0)
- {
- r=a%b;
- a=b;
- b=r;
- }
- return a;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement