Advertisement
luizaspan

Divisores comuns

May 13th, 2015
451
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.35 KB | None | 0 0
  1. // achar divisores comuns entre dois números
  2.  
  3. #include <stdio.h>
  4.  
  5. int main(void)
  6. {
  7.   int a,b,i,x,y;
  8.  
  9.   printf("a= ");
  10.   scanf("%d",&a);
  11.  
  12.   printf("b= ");
  13.   scanf("%d",&b);
  14.  
  15.   for (i=1;i<=1000;i++)
  16.     {
  17.       x=(a/i)*i;
  18.       y=(b/i)*i;
  19.  
  20.       if (x==a && y==b)
  21.     printf("%d é divisor de %d e %d.\n",i,a,b);
  22.  
  23.     }
  24.  
  25.   return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement