or run

npx @tessl/cli init
Log in

Version

Files

docs

function-utilities.mdindex.mdlist-operations.mdmathematical-operations.mdobject-operations.mdstring-processing.md
tile.json

task.mdevals/scenario-5/

Integer Semantics Toolkit

Provide a small utility module that handles common number theory tasks and exposes consistent integer division semantics for mixed-sign inputs.

Capabilities

Normalized common divisors

  • Calling the greatest common divisor helper with 48 and 18 returns 6, and both arguments may be zero with the degenerate case producing 0. @test
  • Passing negative inputs such as -48 and 18 still returns the positive shared divisor 6. @test

Normalized common multiples

  • Computing the least common multiple of 21 and 6 returns 42 and is always non-negative. @test
  • Any input pair that includes 0 yields an lcm of 0 without throwing. @test

Truncated division report

  • Dividing 7 by 3 returns a truncated quotient of 2 and a remainder of 1, preserving the dividend sign on the remainder. @test
  • Dividing -7 by 3 returns a truncated quotient of -2 and a remainder of -1, demonstrating round-toward-zero behavior. @test

Floored division report

  • Dividing -7 by 3 reports a floored quotient of -3 with a modulus of 2 (modulus shares the divisor’s sign), contrasting the truncated result. @test
  • Dividing 7 by -3 reports a floored quotient of -3 with a modulus of -2, preserving dividend = divisor * quotient + modulus. @test

Implementation

@generates

API

/**
 * Returns the greatest common divisor of two integers as a non-negative number.
 */
export function greatestCommonDivisor(a: number, b: number): number;

/**
 * Returns the least common multiple of two integers as a non-negative number.
 */
export function leastCommonMultiple(a: number, b: number): number;

/**
 * Computes truncated integer division (quotient toward zero) and associated remainder.
 */
export function truncatedDivision(dividend: number, divisor: number): { quotient: number; remainder: number };

/**
 * Computes floored integer division (quotient toward negative infinity) and associated modulus.
 */
export function flooredDivision(dividend: number, divisor: number): { quotient: number; modulus: number };

Dependencies { .dependencies }

prelude-ls { .dependency }

Functional utilities used for number theory helpers and integer division semantics. @satisfied-by