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

how to easy edit text, with box? Help.
Hi.
I have a little problem. I'm doing a webpage for my aunt and I would like to make it as easy

Embedding flash object in Else statement
This is my first major project in PHP and I'm having some trouble embedding a flash object in an Els

php mail form text wont appear / javascript included
Guys/gals...

I am running into a problem whereby I have a great piece of javascript code that

Mail Script Problems
I have created a PHP mail script. I am having a problem though. In $body i am trying to put two va

User registration and login
I don't know whether this is the correct forum, if not i apologise but am pretty desperate at the mo

Displaying an image using echo command
I had done a query on my database, one of the fields being an image reference to a directory where a

ECC6 - Single sign-on
We are in the process of upgrading to ECC 6 which will support single sign on with user passwords al

Wierd if else problem
Hi guys,

this probably aint wierd for you, but it seems like php is playin up to me. may b i

GMail like Chat in ASP.NET
Hi,Can anyone suggest me, how to incorporate GMail like chat in my existing ASP.Net application.I wa

PHP5/Zend 2.0 - Resources
PHP5 Snapshots
http://snaps.php.net/

ZEND 2.0 Feature Overview and Design (PDF File

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