buaa_sheng 和 漠墟小仙 都是正确的.
楼主没说用什么编,
我用VB编一个:
function jishu_2n(Num)
dim sum As Long
dim i As Int
for i=2 to Num
sum = sum + i*(i+1)*(i+2)
i = i + 2
next
jishu_2n = sum
end function
Private Sub Form_Load()
Print (jishu_2n(50))
End Sub
C语言
main()
{int i;
long s=0;
for(i=1;i<=50;i++)
s=s+i*(i+1)*(i+2);
printf("%ld",s);
}
int m; // 每项的乘积
int total = 0;
for (int n = 2; n <= 50; n += 2) // 偶数项
{
m = n * (n + 1) * (n + 2); // 每项的乘积
total += m;
}
cout<
long f()
{
int i;
long sum;
sum = 0;
for (i=1 ; i<=50 ; i ++)
{
if (i%2 != 0) continue;
sum += i*(i+1)*(i+2);
}
return sum;
}
long
f()
{
int
i;
long
sum;
sum
=
0;
for
(i=1
;
i<=50
;
i
++)
{
if
(i%2
!=
0)
continue;
sum
+=
i*(i+1)*(i+2);
}
return
sum;
}