I already got this far (see below), but my answer is not correct. The output of my code is equal 0.07. But answer of WolphramAlpha that uses identical algorithm is 0.439818.
Tank you so much. When I set while (k<n) in line 25, answer is equal 0.9. It's a bit better. I've found more accurate method's algorithm. Could you advice how to add condition