I need to write a method where the parameter accepts an interger (n in this case) and returns the sum of the first n terms of the sequence as a double value. So say I put fractionSums(5);
the output would be
1+...+1/5 which would then equal to something like 2.8333~.(final result)
what I have now is:
public static void main(String[] args) {
fractionSums(5);
}
public static void fractionSums(int n) {
Scanner console = new Scanner(System.in);
System.out.print("How many terms do you have? ");
int totalterms = console.nextInt();
}
I'm stuck here and don't know how to go further than this and where to implement n. How would you recommend me on proceeding with this. Do I have to edit this question in anyway?