发布网友 发布时间:2024-10-23 21:35
共1个回答
热心网友 时间:2024-10-27 01:29
用C语言写程序求s。s=3/(2^2)-5/(4^4)+7/(6^6)……+[(-1)^(n-1)]*(2*n+1)/(2*n)^2 把你的fun函数如下改改试试
float fun(float a)
{
int j, m = 1;
float k = 0, s = 0;
for(j = 2; j <= a * 2; j = j + 2)
{
k = (j + 1) / (j * j);
s = s + m * k;
m = -m;
}
return s;
}
3/(1×2×4)+5/(2×3×5)+7/(3×4×6)+……+2n+1/n(n+1)(n+3)
2n+1/n(n+1)(n+3)
= 1/3/n + 1/2/(n+1) + 5/6/(n+3)
c语言 求π π/2=(2/1)*(2/3)*(4/3)*(4/5)*...【(2*n)/(2*n-1)】*【(2*n)/(2*n+1)】
j=(2*n)/(2*n-1);j=(2*n*1.0)/(2*n-1); / 这个除号分子分母若都为整数的话结果会取整,如3/2=1,2/3=0,故要让分子或分母变为浮点型
此外循环条件有点问题,你自个在想想
用c语言编写程序:输入n,求 1-1/2+1/3-1/4+..+1/(2*n-1)-1/(2*n)
#include<stdio.h>int main(){int i,n; double s=0; for(i=1;i<=n+n;i++) if(i%2)s+=1.0/i; else s-=1.0/i; printf("%lf\n",s); return 0;}
#include<stdio.h>
#include<math.h>
void main()
{
float s=0;int i,n;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
s=s+pow(-1,i+1)/(2*i-1);
}
printf("s=%f\n",s);
}
3/2*5/4*7/6*9/8*...2n+1/2n>根号n+1
3/2*5/4*7/6*9/8*...2k+1/2k*2k+3/2k+2>√k+1*2k+3/2k+2
再证左式>√k+2即可
√k+1*2k+3/2k+2>√k+1*2k+3/2k+2
两边平方后,合并同类项
即K+1>0
命题得证
Sn=3/(1*2^2)+5/(2^2*3^2)+7/(3^2*4^2)+...+2n+1/[n^2(n+1)^2],求和!
(2n+1)/[n^2(n+1)^2]
=[(n+1)^2-n^2]/[n^2(n+1)^2]
=(n+1)^2/[n^2(n+1)^2]-n^2/[n^2(n+1)^2]
=1/n^2-1/(n+1)^2
所以原式=1/1^2-1/2^2+1/2^2-1/3^2+……+1/n^2-1/(n+1)^2
=1-1/(n+1)^2
=(n^2+2n)/(n+1)^2
3/1*2^2 、5/2^2*3^2 、 7/3^2*4^2 、 9/4^2*5^2 的前2n+1/n^2(n+1)^2
3/1*2^2
=3*1/1^2*2^2
=(2+1)(2-1)/1^2*2^2
=(2^2-1^2)/1^2*2^2
=2^2/1^2*2^2-1^2/1^2*2^2
=1/1^2-1/2^3
5/2^2*3^2
=(3+2)(3-2)/2^2*3^2
=(3^2-2^2)/2^2*3^2
=3^2/2^2*3^2-2^2/2^2*3^2
=1/2^2-1/3^2
所以7/3^2*4^2=1/3^2-1/4^2
2n+1/n^2(n+1)^2
=1/n^2-1/(n+1)^2
相加则中间正负抵消
所以和=1-1/(n+1)^2=(n^2+2n)/(n^2+2n+1)
C语言:1/(1*3),2/(3*5),……,n/((2*n-1)(2*n+1)),……
#include<stdio.h>int main() { double ret = 0; int i=0; int n = 0; printf("Enter n:"); scanf("%d", &n); for (i=1; i<=n; i++) { ret += 1.0/((2*i-1)*(2*i+1)); } printf("%.3lf\n",ret); return 0;}
用C语言编写程序。s=2!/1!+4!/(1!-3!)+6!/(1!-3!+5!)+8!/(1!-3!+5!-7!)+10!/(1!-3!+5!-7!+9!)
#include "stdafx.h"vc++6.0加上这一行.
#include "stdio.h"
int myfact(int n){
if(n==1) return 1;
else return n*myfact(n-1);
}
void main(void){
int i,f;
double sum,k;
for(f=-1,sum=k=0,i=1;i<10;i+=2)
sum+=myfact(i+1)/(k+=(f=-f)*myfact(i));
printf("The result is %g\n",sum);
}