1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
aev [14]
3 years ago
7

I have to writea piece of code to calculate the factorial of somewhat large numbers so the long long type won't suffize, so usin

g vector, I stumbled upon some issues during run time:
'#include
#include

using namespace std;

vector factorial(short n)
{
vector v, z;
do
{
short m = n%10;
v.push_back(m);
}while(n/=10);

short temp = 0;
int x;
//short m = 0;

while(n-1)
{
for(auto &w : v)
{
x = w*(n-1) + temp;
temp = x/10;
z.push_back(x%10);
}
}
return z;
}

int main()
{
short T;
cin >> T;

vector v;
short temp;
while(T--)
{
cin >> temp;
v.push_back(temp);
}

vector tmp;
for(auto &w : v)
{
tmp = factorial(w);
for(auto i=tmp.end(); i!=tmp.begin(); i--)
cout << *i;
cout << endl;
}
return 0;
}
'
Computers and Technology
1 answer:
Lerok [7]3 years ago
6 0
Your second comment is a solution that is actually almost right!!!
Here's what you should fix:

- The array v[200] should be initialized to all zeros, otherwise it may contain junk. You can simply do this by typing short v[200] = {}; right where you declare it.

- Your while loop should loop from all values of n all the way down to 1. So you need while(n>1) in stead of while(n--<=2)

- At the very end of the while loop, before its closing brace, add an n--; to decrement its value. Alternatively you could have created a do {} while construct.

That's it! After that it correctly calculates all 157 digits of 100!

100! = 93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
You might be interested in
WILL GIVE BRAINLIEST!!! PLEASE HELP!!!
padilas [110]

Answer:

BOI I got ricked rolled!

Explanation:

He done it!

5 0
2 years ago
Now that you have your file holding your data, you need to analyze the data in three different ways that answer questions you po
Alex787 [66]

Answer:

Photosynthesis is a process used by plants and other organisms to convert light energy into chemical energy that, through cellular respiration, can later be released to fuel the organism's metabolic activities

Explanation:

3 0
3 years ago
A(n) ________ is a light-sensitive material used to make a chip.
RSB [31]
The photoresist is a light-sensitive material used to make a chip. Photoresists can likewise be uncovered by electron shafts, creating an indistinguishable outcomes from introduction by light. The primary distinction is that while photons are consumed, storing all their vitality without a moment's delay, electrons store their vitality bit by bit, and scramble inside the photoresist amid this procedure.
3 0
4 years ago
6. What is the correct way to write 340,000,000 in scientific notation? (1 point
givi [52]

Answer:3.4X10^8

Explanation:

4 0
3 years ago
Who is right?
Verdich [7]

Answer:

A) Technician A says a fuel injector pulsed flow test measures steady or maximum fuel flow with the injector pintle and nozzle held fully open.

Explanation:

Through the fuel injector the fuel is injected, and the fuel injector pulsed flow test helps us understand the functioning of the machine at various pulse width, and varying fuel flow ranging from the least to the maximum. The first one is definitely a situation. And hence Technician A is definitely correct. However, Technician B is not correct, as for checking the pintle response you need to change the pulse width. However, technician B is mentioning that he always test with normal pulse width, and this is definitely not true. Hence Technician A is the right person.

5 0
3 years ago
Other questions:
  • The Freemont Automobile Factory has discovered that the longer a worker has been on the job, the more parts the worker can produ
    11·1 answer
  • Assume that scotus is a two-dimensional character array that stores the family names (last names ) of the nine justices on the S
    6·1 answer
  • Which of the following is considered both an input and output peripheral?
    10·1 answer
  • Write a C++ program using a do while loop for (Find the highest score). The program should work for any number of students. Run
    10·1 answer
  • Which three skills are useful for success in any career?
    8·1 answer
  • Write motivation of cache memory​
    9·1 answer
  • What is a Network It’s a system that is used to link two or more computers and name the different types of networks.?
    11·1 answer
  • Dictionaries You are given a dictionary consisting of word pairs. Every word is a synonym the other word in its pair. all the wo
    9·1 answer
  • In the early days of computer technology, which system was justified because data-processing personnel were in short supply, har
    6·1 answer
  • The L-exclusion problem is a variant of the starvation-free mutual exclusion problem. We make two changes: as many as L threads
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!