怎样编写“求15以内奇数的阶乘的和”的代码

来源:百度知道 编辑:UC知道 时间:2024/05/22 05:29:36

DIM A AS LONG
FOR(X=1,X<=15,X=X+2)
FOR(Y=1,Y<=X,Y=Y+2)
Y=Y*Y
NEXT
A=A+Y
NEXT

楼上的VB和c毕竟不能混的
DIM A AS LONG
dim x ,y as interger
FOR x=0 to 15 step =2
FOR y=1 to x
Y=Y*Y
NEXT y
A=A+Y
NEXT x

//用C++解题
#include<iostream.h>

int other(double X);//用int不行,范围有限,不能表示该数.
void main()
{ double b=0;
double X=1;
for(;X<=15;X=X+2)
{
b=other(X)+b;
}

cout<<b<<endl;

}
other(double X)
{int A;
if(X==1)
A=1;
else

A=other(X-1)*X;

return( A);
}