The problem with my code is that when I input 0, the result is 0.0 but whenever I enter anything more than zero, (like 1,2,3,4,5,6, 998...anything) the result is always 1.0 in each case. Is my logic incorrect inside the iteration?
My code:
/*/ Write a y program that will calculate the value of y if the expression
of y is as follows (n is the input):
y = 1/1 + 2/3 + 3/5 + 4/7 + ....... + n/(2n-1) /*/
import static java.lang.System.*;
import java.util.*;
class Practice_Problems04_JavaPrograms_Task04{
public static void main(String[] args){
Scanner orcho = new Scanner(in);
out.println("Please enter the value of n: ");
int n = orcho.nextInt();
double y = 0;
for(int count = 1; count <= n; count++){
y += (count / ((2 * count) - 1));
}
out.println("The summation is, y = " + y);
orcho.close();
}
}