1/3+2/6+3/9+4/12+5/15 java program series. Can anyone plz solve this?
Answers
Answered by
1
Answer:
import java.util.*;
class P1{
public static void main (String [] args) {
double n, d, sum, frac, frac_tmp;
n = 1;
d = 3;
for(int ctr =1; ctr <= 5; ctr++) {
n = n+1;
d = d + 1;
tmp_frac = (n/d) ;
sum = sum + tmp_frac;
}
frac = (1/3);
System.out.println(sum + frac) ;
}
}
Similar questions