c语言 分数阶乘计算
2017-10-13 11:54
302 查看
#include <stdio.h> #include <stdlib.h> #include <math.h> //数学头文件,里面含有pow函数 /* run this program using the console pauser or add your own getch, system("pause") or input loop */ //计算n为1~100的[(-1)^(n+1)*(1/n)]! int main(int argc, char *argv[]) { double jiechenghe=0,n=1; //定义double型阶乘和 for(n;n<=100;n++) //分别计算n从1~100的数 { jiechenghe+=pow(-1,n+1)*(1.0/n); //阶乘和等于n从1~100的数之和,调用pow()函数,实现计算 } printf("n为1~100的[(-1)^(n+1)*(1/n)]!为%.4lf",jiechenghe); //输出阶乘和,double型精确到小数后6为,因为100+的缘故,精确度最高是4 return 0; }
相关文章推荐
- 利用c语言计算n的阶乘及其求和(多种方法)
- 1138: 【C语言训练】计算一个整数N的阶乘
- c语言从键盘输入班级人数,及每个人的分数,计算出平均分数
- c语言:计算分数精确值(%、/真是十分有用的符号,化整为零,化零为整,倒叙,单取数字都可用它们~ )
- 2016/1/6 输出菱形 while语句计算阶乘分数之和
- 计算n的阶乘 C语言
- 【C语言训练】计算一个整数N的阶乘
- 用C语言计算n的阶乘
- C语言:计算分数精确值
- c语言大数阶乘和计算阶乘末尾的0的个数
- C语言使用递归法计算n的阶乘
- C语言实验题——计算评分
- 写一个算法计算n的阶乘末尾0的个数
- 100以内的阶乘计算方法
- 计算200的阶乘
- 使用c语言编写程序,从键盘上任意输入两个数字,并计算出两个数的最小公倍数
- 阶乘计算
- 数学问题——用递归计算阶乘
- 51nod 1189 阶乘分数(分解质因数)
- 计算斐波那契分数前n项之和