Calculating n! using vector


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

#include
#include
#include

Did you know?Explore Trending and Topic pages for more stories like this.
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

SQl num_rows problem
when i try to count rows from an SQL select i get an warning

Code: [Select]$countviews = mysq

Need help with unexpected T-STRING error
I'm a newbie and I'm still learning PHP. However this error has me stumped. I've googled, searched t

Need a Timecode Class...
Not a Time Stamp, Time Code. Format is a bit different. HH:MM:SS:FF where FF is Frames. I dont re

Table control is disappearing from Screen
Hi Experts,

I have a screen with multiple table control(TC). Each table control has two c

Tree Menu
Hi guys,

Can anyone help me making a tree navigation system? I have a site where I'm allowin

Move array index to end
Hey guys,
Quick question:

I have an array that looks like this:
Code: [Select]$var =

cURL Sending File as Post
This is a bit complicated, I'm just hoping someone else has run into this and knows how to do it a d

Navigation include for all site directories
Hi,

I need a navigation include that can deal with directories at different levels on a site.

Oracle Text CTX_DOC.snippet slow
I have a table (FILE_TABLE) that contains a blob column (ft_file) and I have created the following O

Forms Authentication and Refresh at Login page
Hello, When I try to press the Login button in my webapplication at my login.aspx page nothing h

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