spagestic's picture
feat: enhance Gradio interfaces for GCD, prime check, and LCM with detailed descriptions and examples
0fc9213
raw
history blame contribute delete
612 Bytes
import gradio as gr
def gcd(a: int, b: int) -> int:
"""Compute the greatest common divisor of two integers."""
while b:
a, b = b, a % b
return abs(a)
gcd_interface = gr.Interface(
fn=gcd,
inputs=[gr.Number(label="A", precision=0), gr.Number(label="B", precision=0)],
outputs="number",
title="Greatest Common Divisor (GCD)",
description="Compute the greatest common divisor (GCD) of two integers using the Euclidean algorithm. The GCD is the largest integer that divides both numbers without leaving a remainder.",
examples=[[48, 18], [101, 10], [0, 5], [7, 7]],
)