Answer:
See explanation
Step-by-step explanation:
You've already answered the question you posted.
The programming language is not stated. however, the syntax is close to java & c++ and there's a need for alteration on the program to make it run perfectly.
If it is Java,
change
public double fractionSum(int n) {
to
public static double fractionSum(int n) {
If it is C++, change
public double fractionSum(int n) {
to
double fractionSum(int n) {
To call the program from the main method, write:
Java:
System.out.print(fractionSum(n));
C++:
cout<<fractionSum(n);