7mesho wrote:
sum += (1/(5*i));
1 divided by 5 is less than 1. As i increases, your number gets closer and closer to 0, and as it starts at .2, and because you're using int and not float or double, the values in the loop that get added to sum keep getting rounded down to 0. You are returning a double, but inside the method you're using int, you need to use double inside your method also.
If you learned how to use the debugger, and stepped through your code, this would have been apparent to you in no time.