0
It doesnt outpost the correct answer...
public class Program { public static void main(String[] args) { double S=0; double x=2; double n=4; for(double k=1;k<=n+1;k++){ S=S + Math.pow((x+2*k-1),(3/2)); System.out.println(S); } } }
9 Answers
0
for(int k=1;k<=n+1;k++)
{
S=S + Math.pow((x+2*k-1),(3.0/2));
System.out.println(S)
}
+ 1
3/2 results 1 always..
So need of using power function...
Edit:
Angel Halili
I try.. If you say what you are trying...
What is your expected output..?.
0
It outputs 3.0 , 8.0 etc
0
Can u write it ... i dont get it
0
5.1961...., 16.376.... , 34.896.... etc
0
Its like (x+2*k-1)^(3/2) , x =2 so when k=1 its 3^(3/2) = 5.196... but it gives me 3.0
0
Just take a double value in 3/2 means 3.0 or 2.0
In division operation, if both are integers then result is also an integer. If any one is float or double, result will be complete division and return a double value..
0
Thanks it works now
0
Angel Halili you're welcome..