public class Math
extends java.lang.Object
Constructor and Description |
---|
Math() |
Modifier and Type | Method and Description |
---|---|
static int |
getDivisors(int candidate)
Returns the amount of divisors the candidate has, including 1 and the candidate itself.
|
static int |
round(double pDouble)
Wrapper for roundDoubleToInt(double).
|
static int |
roundDoubleToInt(double pDouble)
Rounds the specified double down (2.001 - 2.499 to 2) or up (2.5 - 2.999 to 3) and returns the result as an int.
|
static int |
sumFromXToY(int x,
int y)
Returns the sum of all integer values from a specified lower bound to a specified upper bound, including both
bounds.
|
static int |
sumUpToX(int x)
Returns the sum of all integer values from 1 to the specified upper bound, including 1 and the upper bound.
|
static double |
xToThePowerOfN(double x,
int n)
Calculates x^n.
|
static float |
xToThePowerOfN(float x,
int n)
Calculates x^n.
|
static int |
xToThePowerOfN(int x,
int n)
Calculates x^n.
|
public static int roundDoubleToInt(double pDouble)
pDouble
- the double to round.public static int xToThePowerOfN(int x, int n)
x
- any numbern
- any natural, positive numberpublic static float xToThePowerOfN(float x, int n)
x
- any numbern
- any natural, positive numberpublic static double xToThePowerOfN(double x, int n)
x
- any numbern
- any natural, positive numberpublic static int getDivisors(int candidate)
candidate
- the number to check for its divisor amount.public static int round(double pDouble)
pDouble
- the double to round.public static int sumUpToX(int x)
x
- upper bound.public static int sumFromXToY(int x, int y)
x
- lower bound.y
- upper bound.