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