-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFindingSquareRoots.java
More file actions
29 lines (20 loc) · 1.04 KB
/
FindingSquareRoots.java
File metadata and controls
29 lines (20 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*In olden days finding square roots seemed to be difficult but nowadays it can be easily done using in-built functions available across many languages .
Assume that you happen to hear the above words and you want to give a try in finding the square root of any given integer using in-built functions. So here's your chance.
Input
The first line of the input contains an integer T, the number of test cases. T lines follow. Each line contains an integer N whose square root needs to be computed.
Output
For each line of the input, output the square root of the input integer, rounded down to the nearest integer, in a new line. */
import java.util.Scanner;
public class FindingSquareRoots {
public static void main(String[] args) throws java.lang.Exception {
// your code goes here
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for (int i = 0; i < n; i++) {
int x = sc.nextInt();
double y = Math.sqrt(x);
int z = (int) y;
System.out.println(z);
}
}
}