Any input on why?
package com.codegym.task.task14.task1420;
/*
GCD
*/
import java.util.*;
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
int gcd = 1;
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try {
Integer num1 = Integer.parseInt(reader.readLine());
Integer num2 = Integer.parseInt(reader.readLine());
for(int i = 1; i <= num1 && i <= num2; i++)
{
if(num1%i==0 && num2%i==0)
gcd = i;
}
System.out.println(gcd);
} catch (Exception e) {
throw e;
}
/* loop is running from 1 to the smallest of both numbers
* In this example the loop will run from 1 to 55 because 55
* is the smaller number. All the numbers from 1 to 55 will be
* checked. A number that perfectly divides both numbers would
* be stored in variable "gcd". By doing this, at the end, the
* variable gcd will have the largest number that divides both
* numbers without remainder.
*/
}
}