Having problems with completing this code to a working program and running it. What is the final value of sum? What is the value of i when the loop terminates?
public class SumLargestToSmallest {
int n = 2147483647;
float old_sum = (float) 0.0;
float sum = (float) 1.0; // already added 1.0/i for i = 1
int i = 1;
while (i <= n && sum != old_sum) {
i = i+1;
old_sum = sum;
sum = sum + (float) (1.0 / i);
}
println(i);
println(sum);
}