Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* package whatever; // don't place package name! */
- import java.util.*;
- import java.lang.*;
- import java.io.*;
- /* Name of the class has to be "Main" only if the class is public. */
- class Ideone
- {
- public static void main (String[] args) throws java.lang.Exception
- {
- float x = 9;
- float result = sqrt(x);
- System.out.println(result);
- }
- public static float sqrt(float x) {
- float y = 1;
- int two = 2;
- float temp1 = 0;
- float temp2 = 0;
- float z = 0;
- while (y != z) {
- z = y;
- temp1 = x/y;
- temp2 = temp1 + y;
- y = temp2/two;
- }
- return(y);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement