using System;
using System.Windows.Forms;

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

        public static int Fact(int n)
        {
            int f = 1;
            
            for (int i = 1; i <= n; i++)
                f = f * i;
            
            return f;
        }

        public static int Power(int a, int b)
        {
            int p = 1;
            
            for (int i = 0; i < b; i++)
                p = p * a;
            
            return p;
        }

        public static float S(int x, int n)
        {
            float s = 0;
            
            for (int i = 0; i <= n; i++)
                s += (float)Power(x, i) / Fact(i);
            
            return s;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int x = Convert.ToInt32(textBox1.Text);
            int n = Convert.ToInt32(textBox2.Text);
            
            MessageBox.Show("S = " + S(x, n).ToString());
        }
    }
}