You are viewing a single comment's thread. Return to all comments →
my code
import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { int a, b; Scanner sc = new Scanner(System.in); a = sc.nextInt(); b = sc.nextInt(); if (a == b) { System.out.println(a); } else { int result = gcd(a, b); System.out.println(result); } } public static int gcd(int x, int y) { if (y == 0) { return x; } else { return gcd(y, x % y); } } }
Seems like cookies are disabled on this browser, please enable them to open this website
Computing the GCD
You are viewing a single comment's thread. Return to all comments →
my code