Title Description:
The sequence is defined as follows:
The first item of the sequence is n, and the sum of the first m of the sequence is calculated after the square root of the previous item.
Input
There are several groups of input data, one row for each group, consisting of two integers n (n<10000) and M (m<1000), and the meanings of N and M as described earlier.
Output
For each set of input data, output the summation of the series, each test instance occupies one row, requiring precision to retain 2 decimal places.
Sample input
81 4
2 2
Sample output
94.73
3.41
The implementation is as follows:
Import java.util.*;
public class Main {
public static void Main (string[] args) {
Scanner sc=new Scanner (system.in);
while (Sc.hasnext ()) {
Double N=sc.nextint ();
Double M=sc.nextint ();
Double sum=0;
for (int i=0;i<m;i++)
{
Sum+=n;
N=MATH.SQRT (n);
}
System.out.printf ("%.2f\n", sum);
}
}
}
Square root of the sequence and Java