finding a given root if a number java

Solutions on MaxInterview for finding a given root if a number java by the best coders in the world

showing results for - "finding a given root if a number java"
Lylou
01 Jul 2016
1Scanner sc = new Scanner(System.in);
2        int a = sc.nextInt();//the number of which i want to find the root
3        System.out.println("enter the root:");
4        int rootNum = sc.nextInt();//the N-th number root
5        double powerOf = 1;
6        double sqrt = 0;
7        double b = 1;
8        while (a > b) {
9        	sqrt = powerOf + 0.0000001;//flexible
10        	powerOf = sqrt;
11        	for(int i = 1; i < rootNum; i++) {
12        		b = sqrt*powerOf;
13        		sqrt = b;
14        		}
15        }
Abree
15 Jun 2018
1	Scanner sc = new Scanner(System.in);
2    int a = sc.nextInt();//the number of which i want to find the root
3    System.out.println("enter the root:");
4    int rootNum = sc.nextInt();//the N-th number root
5    double powerOf = 1;
6    double sqrt = 0;
7    double b = 0;
8    while (a > b) {
9    	sqrt = powerOf + 0.0000001;//flexible
10    	powerOf = sqrt;
11    	for(int i = 1; i < rootNum; i++) {
12        	b = sqrt*powerOf;
13        	sqrt = b;
14        	}
15		}