To use the node in your project you should have the rustemb/extra-functions library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.
C++ implementation
struct State {
};
{{ GENERATED_CODE }}
int gcd(int a_, int b_) {
int a = a_;
int b = b_;
if (a < 0) a = -a;
if (b < 0) b = -b;
while (b != 0) {
a %= b;
if (a == 0) return b;
b %= a;
}
return a;
}
void evaluate(Context ctx) {
int a = getValue<input_IN1>(ctx);
int b = getValue<input_IN2>(ctx);
emitValue<output_OUT>(ctx, gcd(a, b));
}