Format code with prettier (#3375)

This commit is contained in:
acbin
2022-10-03 17:23:00 +08:00
committed by GitHub
parent 32b9b11ed5
commit e96f567bfc
464 changed files with 11483 additions and 6189 deletions

View File

@ -2,15 +2,14 @@
* Github : https://github.com/siddhant2002
*/
/** Program description - To find out the inverse square root of the given number*/
/** Wikipedia Link - https://en.wikipedia.org/wiki/Fast_inverse_square_root */
package com.thealgorithms.maths;
public class FastInverseSqrt {
public static boolean inverseSqrt(float number) {
float x = number;
float xhalf = 0.5f * x;
@ -18,15 +17,14 @@ public class FastInverseSqrt {
i = 0x5f3759df - (i >> 1);
x = Float.intBitsToFloat(i);
x = x * (1.5f - xhalf * x * x);
return x == (float)((float)1/(float)Math.sqrt(number));
return x == (float) ((float) 1 / (float) Math.sqrt(number));
}
/**
* Returns the inverse square root of the given number upto 6 - 8 decimal places.
* calculates the inverse square root of the given number and returns true if calculated answer matches with given answer else returns false
*/
public static boolean inverseSqrt(double number) {
double x = number;
double xhalf = 0.5d * x;
@ -37,23 +35,21 @@ public class FastInverseSqrt {
x = x * (1.5d - xhalf * x * x);
}
x *= number;
return x == 1/Math.sqrt(number);
return x == 1 / Math.sqrt(number);
}
/**
* Returns the inverse square root of the given number upto 14 - 16 decimal places.
* calculates the inverse square root of the given number and returns true if calculated answer matches with given answer else returns false
*/
}
/**
* OUTPUT :
* Input - number = 4522
* Output: it calculates the inverse squareroot of a number and returns true with it matches the given answer else returns false.
* 1st approach Time Complexity : O(1)
* Auxiliary Space Complexity : O(1)
* Input - number = 4522
* Output: it calculates the inverse squareroot of a number and returns true with it matches the given answer else returns false.
* 2nd approach Time Complexity : O(1)
* Auxiliary Space Complexity : O(1)
*/
* OUTPUT :
* Input - number = 4522
* Output: it calculates the inverse squareroot of a number and returns true with it matches the given answer else returns false.
* 1st approach Time Complexity : O(1)
* Auxiliary Space Complexity : O(1)
* Input - number = 4522
* Output: it calculates the inverse squareroot of a number and returns true with it matches the given answer else returns false.
* 2nd approach Time Complexity : O(1)
* Auxiliary Space Complexity : O(1)
*/