Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- #include <locale.h>
- int primo = 2;
- void aumentaPrimo();
- int ePrimo(int n);
- int main(){
- setlocale(LC_ALL, "Portuguese");
- int a, b, mmc = 1;
- scanf("%d %d", &a, &b);
- while(a > 1 || b > 1)
- {
- if(a % primo == 0 || b % primo == 0)
- {
- if(a % primo == 0)
- a /= primo;
- if(b % primo == 0)
- b /= primo;
- mmc = mmc * primo;
- }
- else
- aumentaPrimo();
- }
- printf("%d\n", mmc);
- getch();
- }
- void aumentaPrimo(int n)
- {
- int numero = primo + 1;
- while(ePrimo(numero) == 0)
- numero++;
- primo = numero;
- }
- int ePrimo(int n)
- {
- int res, i, div = 0;
- for(i = 1; i <= n; i++)
- {
- if(n % i == 0)
- div++;
- }
- if(div <= 2)
- res = 1;
- else
- res = 0;
- return res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement