Skip to content

Instantly share code, notes, and snippets.

@fernandoguedes
Created August 13, 2013 23:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fernandoguedes/6226804 to your computer and use it in GitHub Desktop.
Save fernandoguedes/6226804 to your computer and use it in GitHub Desktop.
MDC entre P e Q em C
#include <stdio.h>
int main() {
int p,q; //resto, mdcVlr;
printf("Informe P: \n");
scanf("%d", &p);
printf("Informe Q: \n");
scanf("%d", &q);
// resto = p % q;
// mdcVlr = q % resto;
printf("Sem Função: %d\n", mdcVlr);
// printf("Com função: %d\n", mdc(p, q));
}
int mdc(int a, int b) {
if (b == 0) {
return a;
} else {
return mdc(b,a%b);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment