factorial(newbie Q,please heeellp)

Hi,

I am at beginning stage of VC++,and stumped on this question.Find the total of number of factorials ,user inputs.

For eg. user says 5,

ans = 1!+2!+3!+4!+5!

I have done this,but confused where I am going wrong....

#include<iostream>

using std::cin;

using std::cout;

using std::endl;

int main()

{

int num,ans,x,y,answer;

ans=1;

answer=0;

cout<<"enter any integer"<<endl;

cin>>num;

if (num<0)

{

cout<<"u have entered nonnegative integer"<<endl;

}

else if (num==0)

{

cout<<"the"<<num<<"factorial is"<<"1"<<endl;

}

else if (num>0)

{

for(y=1;y<=num;y++)

{

for(x=y;x>=1;x--)

{

ans=x*ans;

}

}

answer=answer+ans;

cout<<"the value of mathematical constant is:"<<answer<<endl;

}

return 0;

}

I will be really grateful,if anybody points me out the right track.

Thankx