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

distinct rows
Hi
version 10.2.0.3

I have a query output something like the following

ID

mysql_real_escape_string making variable equal nothing
i post a form and i post the variable:
Code: $var = $_POST[variable];then i echo $var its what i

PHP - HTTP Digest Authentication - Understanding Code Help
Hi Everyone,

This is my first time on your website and please excuse if I am asking silly que

Had a simple form script that suddenly stopped working
It was made about a year ago and had been working fine. Last time it was known to work for sure was

Code error with Index.php
Error: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/runevid/public_

textfield unchanged
hi,
i want my form to know whether its textbox is unchange or not.

if($textbox == 'unchang

first id from db not showing
I have a php script which displays the content of a mysql table as a html table with sorting, delete

Adding to the next element in a multidimensional array
Hi, I'm trying to add a value to $node->field_spaces['nid'] where x is the next available spo

Time-based image rotation script
I'm trying to write a PHP script that rotates an image based on what time of day it is. I want the

output printing as hexadecmal... XD
Everything works except the calcem call for the totusold and totuprice. The out put shows up as hex.

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