using System;
using System.Windows.Forms;

namespace _7_14
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        public static int GCD(int m, int n)
        {           
            if (n > m)
            {
                int temp = 0;
                temp = m;
                m = n;
                n = temp;
            }
            
            int r = 0;
            
            while (n != 0)
            {
                r = m % n;
                m = n;
                n = r;
            }
            
            return m;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int a = Convert.ToInt32(textBox1.Text);
            int b = Convert.ToInt32(textBox2.Text);
            
            MessageBox.Show("B.M.M: " + GCD(a, b).ToString());
        }
    }
}