aboutsummaryrefslogtreecommitdiff
path: root/tests/upload/gcd_iterative.sy
diff options
context:
space:
mode:
Diffstat (limited to 'tests/upload/gcd_iterative.sy')
-rw-r--r--tests/upload/gcd_iterative.sy17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/upload/gcd_iterative.sy b/tests/upload/gcd_iterative.sy
new file mode 100644
index 0000000..3ed22db
--- /dev/null
+++ b/tests/upload/gcd_iterative.sy
@@ -0,0 +1,17 @@
+int gcd(int a, int b){
+ while(a != 0 && b != 0){
+ if(a > b) a = a % b;
+ else b = b % a;
+ }
+ if(a != 0) return a;
+ else return b;
+}
+
+int main(){
+ int a, b;
+ int c;
+ a = getint();
+ b = getint();
+ c = gcd(a, b);
+ return c;
+}