public static void main(String[] args) { System.out.println("Starting..."); long start = System.nanoTime(); double hypot = 0; hypot = hypotBasic(2, 2); long end = System.nanoTime() - start; System.out.println("Completed (" + (end / 1E6D) + "ms) (hypot=" + hypot + ")!"); } //Advanced hypot private static double hypot(double... array) { double total = 0; for (double v : array) { total+= v * v; } return sqrt(total); } //Basic hyopt private static double hypotBasic(double one, double two) { return sqrt(one * one + two * two); } public static double sqrt(double number) { if(number == 0) return 0; double t; double squareRoot = number / 2; do { t = squareRoot; squareRoot = (t + (number / t)) / 2; } while ((t - squareRoot) != 0); return squareRoot; }