Can you tell the mistake in the code , in one test case it is giving error

import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
long n = scn.nextLong();
String m = scn.next();
long temp = 0, num = 0;
for (int i = m.length() - 1; i >= 0; i–) {
char ch = m.charAt(i);
num += Integer.parseInt(ch + “”) % n * (long) Math.pow(10, temp) % n;
num %= n;
temp++;
}
System.out.println(gcd(n, num));

}

public static long gcd(long a, long b) {

	if (b == 0)
		return a;

	return gcd(b, a % b);
}

}

@ritik hey you have to also check the condition when a <b so you have to swap them if this condition is there.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.