title: Java program that prints out numbers that are divisible by other numbers
body: <p>I  have a program that reads two real numbers and then it prints out all the numbers between these two, that are divisible by 2 or 3 or 5. The program works fine, but when a user enters two really large numbers (for example, 1122222123333 and 214123324434434) the program takes a very long time to calculate the result. I would like to somehow fix the program, so that even for large numbers the result would be printed out instantly.</p>
  
  <p>here is my code so far : </p>
  
  <pre><code>import java.util.Scanner;
  public class Numbers 
  {
      public static void main(String[] args) 
      {
          Scanner sc = new Scanner(System.in);        
          long x = sc.nextLong();   // first number input 
          long y = sc.nextLong();   // second number input            
          long num = 0;            // new variable num -- means all the numbers between these to given input numbers
          long count = 0;            // loop counter - how many numbers are divided by 2 or 3 or 5                        
          for (num = x; x &lt;= num &amp;&amp; num &lt;= y; num++) {                                                    
              if (num % 2 == 0 | num % 3 == 0 | num % 5 == 0) {
                  count = count + 1;             // increasing the counter by 1, so that every time the loop repeats, the counter increases...                                
              }               
          }
          System.out.println(count);  // prints out how many numbers are divided by 2 or 3 or 5 ...       
      }
  }
  </code></pre>