xpile 0.1.616

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
import math


def fact(n: int) -> int:
    return math.factorial(n)


def fact_zero(n: int) -> int:
    # factorial(0) == 1.
    return math.factorial(n)


def binomial(n: int, k: int) -> int:
    # n choose k = n! / (k! * (n-k)!) — exercises factorial in arithmetic.
    return math.factorial(n) // (math.factorial(k) * math.factorial(n - k))