Hi! This WSQ consisted on receiving a number and using it to set the decimal precision for the calculation of e. This one was one of the toughest since it required more tools than the previous WSQs. First, to do the infinite calculation for the value of e, I used two while loops and the formula of the sum of 1/n!. To limit the precision I did two things:

1. I created a loop that turned the input into a space in the decimal, so 2 would give 0.01.

2. I used that value to stop a calculation when an added number was bigger that the limit.

Finally, I searched on the web for functions to limit the precision of floats. I found one called setprecision(), which resulted to be useful for the output value. Here’s the page with the information of the function: http://www.cplusplus.com/reference/iomanip/setprecision/

And here’s the code: https://github.com/CarlosGallegosT/Codes007/blob/master/e.cpp

Image Source: http://www.gogeometry.com/software/word_cloud_sw_e_euler_number.html

                

CC BY 4.0 The number e #WSQ14 by Carlos Gallegos is licensed under a Creative Commons Attribution 4.0 International License.