title: Java code for calculating GCD and LCM of two numbers is working fine but not being accepted on one of the online platforms
body: <p>below is my code for calculating gcd and lcm of two numbers. When i try with different test cases it works fine. But when i try to submit it on online platform it says wrong</p>
  
  <pre><code>package javapractice;
  import java.util.*;
  public class chef_gcdlcm {
  
      public static void main(String[] args) {
          try{
              Scanner input = new Scanner(System.in);
              long t = input.nextInt();
              long l,s,temp;
              while(t--&gt;0){
                  long A = input.nextLong();
                  long B = input.nextLong();
                  temp = 1;
                  if(A&gt;B){ l = A;
                   s = B;}
                  else{ l = B;
                  s = A;              
                  }
                  while(temp!=0){
                      temp = l%s;
                      if(temp!=0){
                          if(temp&gt;s){l = temp;}
                          else{s = temp;}
                      }   
                  }
                  long gcd = (A*B)/s;
                  System.out.println(s +" "+gcd);
              }
              input.close();
          }catch(Exception e){
              e.printStackTrace();
          }
  
      }
  
  }
  </code></pre>