Skip to content

feat(routes-f): gcd and lcm calculator for multiple numbers #729

@davedumto

Description

@davedumto

Summary

Add a GCD/LCM endpoint at app/api/routes-f/gcd-lcm/route.ts. Compute greatest common divisor and least common multiple of multiple integers.

Requirements

  • POST body { numbers: number[], operation?: both|gcd|lcm }
  • Return { gcd?, lcm?, n_count }
  • Use Euclidean algorithm for GCD
  • LCM via lcm(a,b) = |a*b|/gcd(a,b)
  • All inputs must be positive integers
  • Cap array at 100 numbers
  • Use BigInt for intermediate products to avoid overflow
  • Tests: known pairs (12,18), multiple numbers, edge cases (1, primes)

Scope Constraint - READ BEFORE STARTING

All files for this task must live inside app/api/routes-f/. This includes the route handler, helpers/utilities, types, and tests. Do NOT modify, import from, or add files to lib/, utils/, types/, components/, or anywhere else outside app/api/routes-f/. If you need shared logic, duplicate it inside your subfolder. Keeping everything scoped to this folder is intentional - it keeps these tasks independent and mergeable in any order.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stellar WaveIssues in the Stellar wave program

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions