SeriesSum.java
public class SeriesSum
{
public static void main(String[] args)
{
int N = Integer.parseInt(args[0]);
double sum = 0.0;
for (int i = 1; i <= N; i++)
{
sum += 1 / (1.0 * i * i);
sum += 1.0 / (i * i);
sum += 1 / (i * i);
sum += 1.0 / i * i;
}
System.out.println(sum);
System.out.println(Math.sqrt(6.0 * sum));
}
}
No comments:
Post a Comment