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/v4/algorithms
Try itget/v4/algorithms

Parameters

  • methodstringrequired

    The algorithm to use (see available methods below)

    • anagram
    • bubblesort
    • factorial
    • gcd
    • isprime
    • fibonacci
    • palindrome
    • primelist
    • primefactors
    • reverse
    • roman
  • 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 value2Limits
anagramChecks if two strings are anagramsYesMax 1000 chars
bubblesortSorts an array of numbers, separated by commasNoMax 1000 elements
factorialCalculates the factorial of a number between 0 and 170No0–170
gcdComputes the greatest common divisor of two numbersYes1–100,000
isprimeChecks if a number is primeNo1–100,000
fibonacciCalculates a Fibonacci sequence up to a given numberNo0–1000
palindromeChecks if a string is a palindromeNoMax 1000 chars
primelistReturns a list of prime numbers up to a given numberNo2–10,000
primefactorsReturns the list of prime factors of a numberNo1–100,000
reverseReverses a stringNoMax 1000 chars
romanConverts between Roman numerals and numbers (1–3999)No1–3999

Response Fields

  • answernumber|string|boolean|number[]

    The algorithm result

Code Examples

Error Handling

If parameters are missing or invalid, the API will return an error:

  • 400Please provide a valid algorithm (?method={algorithm})The method parameter is missing or invalid
  • 400Invalid inputThe value exceeds the method's constraints or limits