Math
Endpoints for various math functions.
Base URL
https://api.kyle.so/math/prime
Calculates if n is a prime.
GET /prime/:nExample:
GET /math/prime/20
Response:
{
"isPrime": boolean,
"divisors": [
number, number
],
"message": string
}Constraints:
nmust be > 1nmust be a number
Errors:
400: Invalid parameter
/fibonacci
Calculates the first n digits in the Fibonacci Sequence
GET /fibonacci/:nExample:
GET /math/fibonacci/5
Response:
{
"sequence": number[] (of size n),
"message": string
}Constraints:
0 <
n< 1476nmust be a number
Errors:
400: Invalid parameter
/random-number
Generates a random number between x and y (if x and y are omitted, x=0 y=1000)
GET /random-number?min=x&max=yExample:
GET /math/random-number?min=10&max=100
Response:
{
"number": number,
"message": string,
"range": [x,y]
}Constraints:
x (min)<y (max)xandymust be numbers
Errors:
400: Invalid parameter(s)
/factorial
Calculates the factorial of n (n!)
GET /factorial/:nExample:
GET /math/factorial/5
Response:
{
"number": number,
"message": string
}Constraints:
0 <
n< 170nmust be a number
Errors:
400: Invalid parameter
/sqrt
Calculates the square root of n
GET /sqrt/:nExample:
GET /math/sqrt/25
Response:
{
"result": number,
"message": string
}Constraints:
n> 0nmust be a number
Errors:
400: Invalid parameter
/abs
Calculates the absolute value of n
GET /abs/:nExample:
GET /math/abs/-5
Response:
{
"result": number,
"message": string
}Constraints:
nmust be a number
Errors:
400: Invalid parameter
/round
Rounds n to the nearest integer
GET /round/:nExample:
GET /math/round/5.5
Response:
{
"result": number,
"message": string
}Constraints:
nmust be a number
Errors:
400: Invalid parameter
/ceil
Rounds n up to the nearest integer
GET /ceil/:nExample:
GET /math/ceil/5.1
Response:
{
"result": number,
"message": string
}Constraints:
nmust be a number
Errors:
400: Invalid parameter
/floor
Rounds n down to the nearest integer
GET /floor/:nExample:
GET /math/floor/5.9
Response:
{
"result": number,
"message": string
}Constraints:
nmust be a number
Errors:
400: Invalid parameter
/sin
Calculates the sine of n (in radians)
GET /sin/:nExample:
GET /math/sin/0
Response:
{
"result": number,
"message": string
}Constraints:
nmust be a number
Errors:
400: Invalid parameter
/cos
Calculates the cosine of n (in radians)
GET /cos/:nExample:
GET /math/cos/0
Response:
{
"result": number,
"message": string
}Constraints:
nmust be a number
Errors:
400: Invalid parameter
/tan
Calculates the tangent of n (in radians)
GET /tan/:nExample:
GET /math/tan/0
Response:
{
"result": number,
"message": string
}Constraints:
nmust be a number
Errors:
400: Invalid parameter
/log
Calculates the natural logarithm of n
GET /log/:nExample:
GET /math/log/10
Response:
{
"result": number,
"message": string
}Constraints:
n> 0nmust be a number
Errors:
400: Invalid parameter
/log10
Calculates the base 10 logarithm of n
GET /log10/:nExample:
GET /math/log10/10
Response:
{
"result": number,
"message": string
}Constraints:
n> 0nmust be a number
Errors:
400: Invalid parameter
/log2
Calculates the base 2 logarithm of n
GET /log2/:nExample:
GET /math/log2/10
Response:
{
"result": number,
"message": string
}Constraints:
n> 0nmust be a number
Errors:
400: Invalid parameter
/exp
Calculates e raised to the power of n
GET /exp/:nExample:
GET /math/exp/1
Response:
{
"result": number,
"message": string
}Constraints:
nmust be a number
Errors:
400: Invalid parameter
/pow
Calculates x raised to the power of y
GET /pow/?base=x&exponent=yExample:
GET /math/pow/?base=2&exponent=3
Response:
{
"result": number,
"message": string
}Constraints:
xandymust be numbersxandymust be present
Errors:
400: Invalid parameter(s)
Last updated
Was this helpful?