using
System;using
System.Collections.Generic;using
System.Text;namespace
ConsoleApplication1{
class Program{
static void Main(string[] args){
double x = Convert.ToDouble(Console.ReadLine()); int n = Convert.ToInt16(Console.ReadLine()); Console.WriteLine("{0}", Program.exp1(x, n)); Console.ReadLine();
}
static double power(double x, int n){
if ((x == 0) || (x == 1)) return x;
double p = 1; for (int i = 1; i <= n; i++)
p *= x;
return p;}
/***************************************************************************************************/ static long fact(int n){
long f = 1; if (n <= 1) return 1; for (int i = 1; i <= n; i++)f = f * i;
return f;}
static double exp1(double x, int n){
double sum = 0; for (int i = 0; i <= n; i++)sum += power(x, i) / fact(i);
return sum;}
}
}
سمانه طالبی