-
Notifications
You must be signed in to change notification settings - Fork 704
/
MDC e MMC.cs
42 lines (36 loc) · 992 Bytes
/
MDC e MMC.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
int num1 = int.Parse(Console.ReadLine());
int num2 = int.Parse(Console.ReadLine());
int cont = 2;
int result = 1;
for (int i = 1; i <= num1 || i <= num2; i++)
{
if (i == 1)
{
continue;
}
else if (num1 % i == 0 && num2 % i == 0)
{
num1 /= i;
num2 /= i;
result *= i;
i--;
}
}
int MDC = result;
int mmc = num1 * num2 / MDC;
Console.WriteLine("O MDC é " + MDC);
Console.WriteLine("Já o mmc é \n" + mmc);
}
}
}