编写一个名为 calcSeries 的方法,该方法计算并返回以下系列中 y 的值:
其中 n 和 x 是两个输入整数,y 是返回的双精度值。
假设 x > 0, n>=0
编写一个名为 calcSeries 的方法,该方法计算并返回以下系列中 y 的值:
其中 n 和 x 是两个输入整数,y 是返回的双精度值。
假设 x > 0, n>=0
public class LabClass{
public double calcSeries(int x,int n){
double y=1;
for (int i=1;i<=n;i++){
y+=i*i*i/Math.sqrt(i+x);
}
return y;
}
public static void main(String[] args) {
double y=new LabClass().calcSeries(8,4);
}
}