How do one write a c++ code to solve 150!
If you want it as a double:
 ``12345678910`` ``````#include #include using namespace std; int main() { int n; cout << "Input n: "; cin >> n; cout << "Factorial is " << tgamma( n + 1.0 ) << endl; }``````

 ```Input n: 150 Factorial is 5.71338e+262```

If you want the exact answer as a long string of digits then you will either have to use a big-number class or simply write a short routine to do long multiplication (the same way as by hand) with a vector<int>
 ```Input n: 150 57133839564458545904789328652610540031895535786011264182548375833179 82912484539839312657448867531114537710787874685420416266625019868450 44663559491959220665749425920957357789293253572904449624724054167907 22118445437122269675520000000000000000000000000000000000000```

First, you need a concrete problem statement, because I can solve 150 in ways you haven’t even thought of yet.

Next, you need to review your lecture notes and book. Your homework assignments are typically designed to make you use stuff you should have just learned. So, for example, if your last class was all about “loops”, chances are your homework will require you to use a loop.

Third, figure out how you would solve it on a piece of paper. Try to design your code to do the same thing / think the same way.

Finally, write some code and give it a compile or two. Figure out what works and what doesn’t. When you get stuck, post back here with the following information:

• [code] your code [/code]
• what it is supposed to do
• what it does instead (if it compiles)
• the first few lines of complaint your compiler spits out (if it does not compile)

Otherwise, you are just asking us to do your homework, and many of us personally find it much more entertaining to watch wimps squirm and fail than become someone we have to work with later.

Don’t be a wimp.
Topic archived. No new replies allowed.