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

SAP Project Module
I have seen in the SAP Project Module,plan cost and budget are not equal and even difference is sign

Share admin accross websites
I'm using .net memberships and roles in one of my sites, but I need to be able to share logins and p

show the direct link into href
I want to display link on the page. i am fetching the data(URL) from database,actually before that i

C++ API to Oracle dB
I need to perform a select command to the Oracle dB to obtain information from a table.
What libr

Timer control causing error
I recently decided to add a timer control to an existing page that uses AJAX on my site. As soon as

understanding functions and classes
Code: [Select]
class person {
var $name = "Jimmy Goe";

function get_nam

Structure Question - One Table or One Table Per Record Set?
I have a web app (mySQL and PHP) which allows people to create an item with up to 200 records which

Save file by click
Hello.
I'm not understand how to save file from page. I'd like make link to file with save abil

Displaying Site Logo/Icon on a Title tag
really need some help out here. I want to insert a Logo/Icon just like the one close to the "PH

PHP4 to PHP5 Conversion
Hi Everyone,

I am working on a site that is built up on PHP4 and each page is being started f

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