Skip to content
moxon home

Algorithms

The /algorithms endpoint provides several algorithms to use as parameters. You can input one or two values depending on the algorithm.

gethttps://api.moxon.dev/v2/algorithms

Parameters

  • methodstringrequired

    The algorithm to use (see available methods below)

  • valuestringrequired

    The value to use in the algorithm. Must contain at least one character

  • value2stringoptional

    The second value to use if necessary. Must contain at least one character

Available Methods

MethodDescriptionRequires value2
anagramChecks if two strings are anagramsYes
bubblesortSorts an array of numbers, separated by commasNo
factorialCalculates the factorial of a number between 0 and 170No
gcdComputes the greatest common divisor of two numbersYes
isprimeChecks if a number is primeNo
fibonacciCalculates a Fibonacci sequence up to a given numberNo
palindromeChecks if a string is a palindromeNo
primelistReturns a list of prime numbers up to a given numberNo
primefactorsReturns the list of prime factors of a numberNo
reverseReverses a stringNo

Request Example

Request
GET /v2/algorithms?method=gcd&value=17&value2=493

Response

Response
{
    "answer": 17
}

cURL

cURL
curl -X GET "https://api.moxon.dev/v2/algorithms?method=gcd&value=17&value2=493"

Error Handling

If the value of method or value is empty or invalid, or if value2 is required but empty, an error will be returned.