Skip to content

Commit 355d4c1

Browse files
authored
added precision_root_algo
1 parent 8b29c6c commit 355d4c1

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Misc/root_precision

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import java.io.*;
2+
import java.util.*;
3+
import java.text.*;
4+
import java.math.*;
5+
import java.util.regex.*;
6+
7+
public class Solution {
8+
9+
public static void main(String[] args) {
10+
Scanner scn = new Scanner(System.in);
11+
12+
int N = scn.nextInt();
13+
int P = scn.nextInt();
14+
15+
System.out.println(squareRoot(N, P));
16+
}
17+
18+
public static double squareRoot(int N, int P) {
19+
double sqrt = 0;;
20+
21+
// Write your code here
22+
double root = Math.pow(N, 0.5);
23+
int pre = (int) Math.pow(10, P);
24+
root = root * pre;
25+
sqrt = (int)root;
26+
return (double)sqrt/pre;
27+
}
28+
}

0 commit comments

Comments
 (0)