Files
cs420/examples/c/gcd.c
Janggun Lee 72dadc608d Various quality-of-life improvements (ideas from @33577 )
* Very basic `hello_main.c`
* Big starting hint to `write_c`
* Better error messages on failed test
  * TODO: also improve it for asmgen, but not sure how to do it in a good way
2025-02-25 00:28:55 +09:00

19 lines
254 B
C

int gcd(int a, int b) {
a = (a > 0) ? a : -a;
b = (b > 0) ? b : -b;
while (a != b) {
if (a > b) {
a -= b;
} else {
b -= a;
}
}
return a;
}
int main() {
return gcd(18, 21) == 3;
}