xref: /wasmtime-44.0.1/docs/examples-gcd.md (revision 97e0b7db)
1*97e0b7dbSAlex Crichton# Calculating the GCD
2*97e0b7dbSAlex Crichton
3*97e0b7dbSAlex CrichtonYou can also browse this source code online and clone the wasmtime
4*97e0b7dbSAlex Crichtonrepository to run the example locally:
5*97e0b7dbSAlex Crichton
6*97e0b7dbSAlex Crichton* [Rust](https://github.com/bytecodealliance/wasmtime/blob/main/examples/gcd.rs)
7*97e0b7dbSAlex Crichton* [C](https://github.com/bytecodealliance/wasmtime/blob/main/examples/gcd.c)
8*97e0b7dbSAlex Crichton* [C++](https://github.com/bytecodealliance/wasmtime/blob/main/examples/gcd.cc)
9*97e0b7dbSAlex Crichton
10*97e0b7dbSAlex CrichtonThis example shows off how run a wasm program which calculates the GCD of two
11*97e0b7dbSAlex Crichtonnumbers.
12*97e0b7dbSAlex Crichton
13*97e0b7dbSAlex Crichton## Wasm Source
14*97e0b7dbSAlex Crichton
15*97e0b7dbSAlex Crichton```wat
16*97e0b7dbSAlex Crichton{{#include ../examples/gcd.wat}}
17*97e0b7dbSAlex Crichton```
18*97e0b7dbSAlex Crichton
19*97e0b7dbSAlex Crichton## Host Source
20*97e0b7dbSAlex Crichton
21*97e0b7dbSAlex Crichton<!-- langtabs-start -->
22*97e0b7dbSAlex Crichton
23*97e0b7dbSAlex Crichton```rust
24*97e0b7dbSAlex Crichton{{#include ../examples/gcd.rs}}
25*97e0b7dbSAlex Crichton```
26*97e0b7dbSAlex Crichton
27*97e0b7dbSAlex Crichton```c
28*97e0b7dbSAlex Crichton{{#include ../examples/gcd.c}}
29*97e0b7dbSAlex Crichton```
30*97e0b7dbSAlex Crichton
31*97e0b7dbSAlex Crichton```cpp
32*97e0b7dbSAlex Crichton{{#include ../examples/gcd.cc}}
33*97e0b7dbSAlex Crichton```
34*97e0b7dbSAlex Crichton
35*97e0b7dbSAlex Crichton<!-- langtabs-end -->
36