Skip to content

GreatestCommonDivisor

[Source]

Get greatest common divisor of x and y.

Providing 0 will result in an error.

Example usage:

use "math"

actor Main
  new create(env: Env) =>
    try
      let gcd = GreatestCommonDivisor[I64](10, 20)?
      env.out.print(gcd.string())
    else
      env.out.print("No GCD")
    end
primitive val GreatestCommonDivisor

Constructors

create

[Source]

new val create()
: GreatestCommonDivisor val^

Returns


Public Functions

apply[A: Integer[A] val]

[Source]

fun box apply[A: Integer[A] val](
  x: A,
  y: A)
: A ?

Parameters

  • x: A
  • y: A

Returns

  • A ?

eq

[Source]

fun box eq(
  that: GreatestCommonDivisor val)
: Bool val

Parameters

Returns


ne

[Source]

fun box ne(
  that: GreatestCommonDivisor val)
: Bool val

Parameters

Returns