← All procedures

rational.gcd

This function gives the greatest common divisor of `|a|` and `|b|`. The result for `0` and `0` is `0`.

CLI
Package
@procedures/rational · README
Path
["rational","gcd"]
CLI
mark rational gcd --a <string> --b <string>
As data
{"$proc":["rational","gcd"],"input":{}}

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/rational/register"; // registers its procedures

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["rational","gcd"], { a: "<a>", b: "<b>" });
console.log(JSON.stringify(result));

From the command line

$ mark rational gcd --a <string> --b <string>

As data, in a program

{ "$proc": ["rational", "gcd"], "input": { "a": "<a>", "b": "<b>" } }

Input

FieldTypeRequiredDefaultDescription
astringyesAn integer.
bstringyesAn integer.

Output

The schema does not list fields (string).

JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "a": {
        "type": "string",
        "pattern": "^-?(0|[1-9][0-9]*)$",
        "x-procedures-codec": "bigint",
        "description": "An integer."
      },
      "b": {
        "type": "string",
        "pattern": "^-?(0|[1-9][0-9]*)$",
        "x-procedures-codec": "bigint",
        "description": "An integer."
      }
    },
    "required": [
      "a",
      "b"
    ],
    "additionalProperties": false
  },
  "output": {
    "type": "string",
    "pattern": "^-?(0|[1-9][0-9]*)$",
    "x-procedures-codec": "bigint"
  }
}