xpile 0.1.615

Polyglot transpile workbench (Python/C/C++/Rust/Ruchy/Lean ↔ Rust/Ruchy/PTX/WGSL/SPIR-V) with provable contracts at every layer.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import math


def gcd2(a: int, b: int) -> int:
    return math.gcd(a, b)


def reduce_fraction(num: int, den: int) -> int:
    # common idiom: divide by the gcd to reduce.
    g = math.gcd(num, den)
    return num // g


def gcd_negative(a: int, b: int) -> int:
    # gcd is over absolute values.
    return math.gcd(a, b)