mbalves Posted April 12, 2008 at 11:44 PM Report Share #178670 Posted April 12, 2008 at 11:44 PM Alguem me poderia explicar como fazer em java um ciclo para calcular o maximo divisor comum? cumprimentos Link to comment Share on other sites More sharing options...
magician Posted April 12, 2008 at 11:47 PM Report Share #178671 Posted April 12, 2008 at 11:47 PM Só sei fazer recursivamente com ciclo também dá mas é mais complicado. public int mdc( int x, int y ){ if(x == y){ return x; } else if( y > x ){ return mdc( x, y-x ); } else if( x > y ){ return mdc( x - y, y ); } return 0; } I haven’t lost my mind; it’s backed up on DVD somewhere! Link to comment Share on other sites More sharing options...
QuickFire Posted April 12, 2008 at 11:49 PM Report Share #178672 Posted April 12, 2008 at 11:49 PM http://pt.wikipedia.org/wiki/Algoritmo_de_Euclides Acho que até já tens isso implementado em Java e tudo, apesar da tua pergunta ser uma pergunta de algoritmia. Não é nada de muito complicado. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now