Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
> Here is what I get on my 32 bit PC. Please note that I'm not using any kind of multiprecision library.
What's your point?
Garbage in is garbage out perhaps.
> The factorial of i 22 is: 1124000727777607680000
> The factorial of i 23 is: 25852016738884978212864
Explain how multiplying 3 with 0 gets you 4.
Factorials accumulate increasingly long tails of zeros - any simple desk check of the results would have spotted that one.
Your results ceased being accurate when it sailed past what can be stored in unsigned long long (64 bits).
Post your code.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
By all means, if you have something better, post it.
Really anything at this point is "something better" because your output was said to be faulty. At that point, it stopped being amusing. No one else here claimed to be able to fit 158 digit numbers in 32 bits and 10 lines of code.
Quzah.
Hope is the first step on the road to disappointment.
The fact that we don't have anything better doesn't justify your code is completely wrong.
In fact, if you really wanted to compute such large factorials the only way I can imagine doing it is by using vectors to store digits individually and performing each multiplication between the digits manually, thus storing the huge result in another vector of digits, rather than in some integer type variable. However, that is a very tedious and complex operation and I will be impressed to see that written in 10 lines of code like you claimed.
Okay, but it's funny how some of the people on here called me an idiot, yet these same people can't produce, in this case, a less buggy solution.