title: Number of hcf between two numbers
body: <p>I want to print the number of hcf between two numbers using scanner class.I tried this code, this is giving an error.How can same be done by using file handling.</p>
  
  <pre><code>Execution failed.
  java.util.NoSuchElementException : No line found
  Stack Trace:
  Exception in thread "main" java.util.NoSuchElementException: No line found
  at java.util.Scanner.nextLine(Scanner.java:1540)
  at TestClass.main(TestClass.java:13)  
  
  
    import java.util.*;
   class TestClass {
  public static void main(String args[] ) throws Exception {      
  
      Scanner s = new Scanner(System.in);
      String num1 = s.nextLine();  
       String num2 = s.nextLine(); 
      int n1 =Integer.parseInt(num1);
      int n2 =Integer.parseInt(num2);      
  
      int max=0;
      int gcd = 1;
      if (n1&lt;=n2)
      {
          max=n1;
      }
          else {
              max=n2;
          }
          int count=0;
      for(int i = 1; i &lt;= max; ++i)
      {
          if((n1%i==0) &amp;&amp; (n2%i==0))
          gcd=i;
          count++;
      }
  
      System.out.println(" "+ count);
  }
  }
  </code></pre>