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

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

SMTP server...
I recently found a tutorial online on SMTP authentification for sending emails from webpages, here i

php title problem
Hi,

I am having a problem managing my page title with PHP.

Currently I have my <

Alternate messaging
I have 4 strings in MySQL db1

$string1 : Hello
$string2 : Hi
$string3 : Great
$strin

storing results of a function - previous result overwritten with new result
I have created a function to validate input.

function validate_dimension($value,$name) {
<

constructor ?
i have written this program and made 3 constructors in the class and i want to call them in the main

INSERT data problem!
After having an string with apostrophes ', double quotes " or any other special characters, suc

ImageCreate()
When I create an image and add text to it I want my text to be replaced with a PNG image, because th

Coding question?
Hey guys, I have a quick question. If I want to make a way for people to pay for health in my game,

pspell
using pspell, is it possible to get words that would be best in the current phrase?

For examp

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