Dim I as Integer, J as Integer, Sum as Double, Total as Double
For I = 1 to 2004
For J = 1 to I
Sum =Sum +J
Next J
Total=Total + Sum
Next I
print Total
我知道是上面这个程序,但是我的疑问是过程能不能有高人帮我分析下,另外我疑惑的是,我把2004改成5来验证这个程序正确否,得到的答案是70,我自己用笔算是35呢,为什么呢?
...和:s=1+(1+2)+(1+2+3)+(1+2+3+4)+…+(1+2+3+4+…+n)?
sum([sum(range(i+1)) for i in range(1,31)])
编程实现求Sum=1+(1+2)+(1+2+3)+(1+2+3+4)+ …… +(1+2+3+4+ … +...
Sub test()n = InputBox("输入一个整数")su = 0 For i = 1 To n * 1 For j = 1 To i - 1 su = su + j Next su = su + i Next Print su End Sub
编写一个程序,计算下式之和: 1+(1+2)+(1+2+3)+(1+2+3+4)+……+(1+2+
int main(int argc, char** argv){ int num = 0; char *temp[100];int sum = 0, tmp = 0, pos = 0;do{ printf("请输入 N 值:");scanf("%d",&num) || scanf("%s", (char*)temp);if(num >= 1)break;}while(1);while(pos < num){ tmp += ++pos;sum += tmp;} ...
如何用c语言编程 求1+(1+2)+(1+2+3)+(1+2+3+4)……+(1+2+3+……+n
include<stdio.h>int main(){ int i,j,an,sum,n; scanf("%d",&n); for(i=1,sum=0;i<=n;i++) { for(j=1,an=0;j<=i;j++) an+=j; sum+=an; } printf("%d",sum); return 0;}
用C语言编写程序,求s=1+(1+2)+(1+2+3)+(1+2+3+4)+(1+2+3+4+…n)。
main(){ int n,i,j;long s=0;printf("Please input n:");scanf("%d",&n);for(i=1;i<=n;i++)for(j=1;j<=i;j++){ s+=j;} printf("s=1+(1+2)+(1+2+3)+(1+2+3+4)+(1+2+3+4+…+n)=%ld",s);} 利用for循环,根据式子的特性进行相加,得出最终结果。
用Java编写一个程序,计算s=1+(1+2)+(1+2+3)+…+(1+2+3+4+5+…+100...
public static void main(String[] args) { int sum = 0;for(int i = 1; i <= 100; i++){ int sumI = 0;\/\/calc (1+2+3) for 3 for(int j = 1; j <= i; j++){ sumI = sumI + j;} sum = sum + sumI;} System.out.println("1+(1+2)+(1+2+3)+…+(1+2+...
1+(1+2)+(1+2+3)+...+(1+2+3+...+n)
1+2+3+...+n=n(n+1)\/2=n^2\/2+n\/2 1+(1+2)+(1+2+3)+...+(1+2+3+...+n)=(1^2+2^2+3^2+---+n^2)\/2+(1+2+3+---+n)\/2 =n(n+1)(2n+1)\/12+n(n+1)\/4 =n(n+1)(n+2)\/6
求解s=1+(1+2)+(1+2+3)+...+(1+2+3...+n)
3^3-2^3=2*3^2+2^2-3 4^3-3^3=2*4^2+3^2-4 ...n^3-(n-1)^3=2*n^2+(n-1)^2-n 各等式全相加 n^3-1^3=2*(2^2+3^2+...+n^2)+[1^2+2^2+...+(n-1)^2]-(2+3+4+...+n)n^3-1=2*(1^2+2^2+3^2+...+n^2)-2+[1^2+2^2+...+(n...
...s=1+1\/(1+2)+1\/(1+2+3)+1\/(1+2+3+4)+...+1\/(1+2+3+...+n)_百度知...
include <stdio.h> int main(){ double s=0;int n,t=0;printf("请输入n\\n");scanf("%d",&n);int i;for(i=1;i<=n;i++){ t+=i;s+=1.0\/t;} printf("结果为:%f",s);return 0;}
Python求1+1+2+1+2+3+1+2+3+4+……+1+2+3+4+5…n前n项的和。
n=9listb=[]sumb=0for x in range(1,n+1): for y in range(1,x+1): listb.append(str(y)) lineb='+'.join(listb) sumb+=yprint("{}的和为{}".format(lineb,sumb))n可以任意改成你想要的数字 ...