Spaces:
Runtime error
Runtime error
File size: 604 Bytes
9b3b8c8 291349f 9b3b8c8 291349f 0fc9213 291349f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
from .gcd import gcd
import gradio as gr
def lcm(a: int, b: int) -> int:
"""Compute the least common multiple of two integers."""
if a == 0 or b == 0:
return 0
return abs(a * b) // gcd(a, b)
lcm_interface = gr.Interface(
fn=lcm,
inputs=[gr.Number(label="A", precision=0), gr.Number(label="B", precision=0)],
outputs="number",
title="Least Common Multiple (LCM)",
description="Compute the least common multiple (LCM) of two integers. The LCM is the smallest positive integer that is a multiple of both numbers.",
examples=[[4, 6], [21, 6], [0, 5], [7, 7]],
)
|