Calculating n! using vector


Posted on 16th Feb 2014 07:03 pm by admin

#include
#include
#include

using namespace std;
int main()
{

//declaration
int i,n,num,val,temp,j,l;
vector< vector > V;
vector v;


//calculation part
v.push_back(1);V.push_back(v);v.clear();
for(i=1;i<=100;i++)
{
temp = 0;v.clear();
l = V[i-1].size();
for(j=0;j {
val = V[i-1][j]*i+temp;
v.push_back(val%10);
temp = val/10;
}
if(temp != 0) v.push_back(temp);
V.push_back(v);
}


//input output
scanf("%d",&n);
while(n--)
{
scanf("%d",&i);
for(j=V[i].size()-1;j>=0;j--)
cout< printf("n");
}
return 0;
}

well the code gives correct answer till 33! and starts printing garbage after that i dont get why plz help1

No comments posted yet

Your Answer:

Login to answer
177 Like 7 Dislike
Previous forums Next forums
Other forums

Motivational Posters
Hello,

I wonder how can i do them in php. Are there any sample codes that you can show me?

Asset Transfer from One plant to another within same company code
Hi,

Please advise how to transfer one asset from one plant to another plant within same c

problem with script manager
Hi iam using Net.2005.I have created ajax enabledwebsite.i have master page in which i have script m

Check premium expire
Hi,

I am making a simple file hosting site and want to check if users premium subscriptions h

Click counter to ignore traffic from search bots
I have a click counter on my site that...well, counts the number of clicks a link gets on the frontp

http to https
Hi,

Is there any specific method/condition to move an http:// page to https:// ?

How to add functionality to a simple php calender?
Hello everyone,

I have just finished creating a simple php calander. Can someone point

insert/update functions for mysql, what do you think?
I am working on two really simple functions that automatically generate (and execute) insert and upd

Giving the below syntax error
Dear Experts,

I have used 2 buttons in gui status as display and cjhange.When the user wi

HELP with mysql_real_escape_string
I'm looking to remove apostrophes completely when someone enters lyrics but don't have a clue how to

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash