你要用什么语言写的呢?我用c#写了一个,程序如下:
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static int Factorial(int n) //求n的阶乘
{
if (n == 0 || n == 1)
return 1;
else
return n * Factorial(n - 1);
}
static void Main(string[] args)
{
double sum = 0;
for (int i = 1; i <= 10; i++)
{
sum += Math.Pow(-1, i) * Math.Sin(Program.Factorial(i));
}
Console.WriteLine(sum.ToString());
Console.Read();
}
}
}
运行结果如图,保留两位小数的话结果是-2.27