The problem
Write a program to sum the following series:
1 + 3 + 5 + 7 + 9 + 11 + ... + 95 + 97
3 5 7 9 11 13 97 99
Breaking it down
public static void main(String[] strings) {
double total = 0.0;
for (int i = 1; i <= 97; i += 2) {
total += (double) i / (i + 2);
}
System.out.println("Total is: " + total);
}
Output
Total is: 45.124450303050196