Respuesta :
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
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