Gcd N Lines Of Input And Calculate The Gcd

import java.util.Scanner;
class Main{
    public static void main(String args[])
{
    int gcd=1;
    Scanner sc = new Scanner(System.in);
    System.out.println("ENTER no of lines ");
    int N=sc.nextInt();
    System.out.println("no of lines "+N);
    for(int i=1;i<=N;i++)
    {
        int A =sc.nextInt();
        int B =sc.nextInt();
    for(int j=1;j<=Math.min(A,B);j++)
    {
        if((A%j==0)&&(B%j==0)){
            gcd=j;
        }

    }
    System.out.println("gcd is "+gcd);
}
}
}