title: Java:Counting prime numbers
body: <p>So I have written this code, and I am proud of it since I have not been coding for a long time. What it does, it asks for a number and then prints all the Prime numbers there are from 1 to that number.</p>
  
  <pre><code>import java.util.Scanner;
  class PrimeNumberExample {
  
      public static void main(String args[]) {
  
          //get input till which prime number to be printed
          System.out.println("Enter the number till which prime number to be printed: ");
          int limit = new Scanner(System.in).nextInt();
  
          //printing primer numbers till the limit ( 1 to 100)
          System.out.println("Printing prime number from 1 to " + limit);
          for(int number = 2; number&lt;=limit; number++){
              //print prime numbers only
              if(isPrime(number)){
                  System.out.println(number);
              }
          }
  
      }
  
      /*
       * Prime number is not divisible by any number other than 1 and itself
       * @return true if number is prime
       */
      public static boolean isPrime(int number){
          for(int i=2; i&lt;number; i++){
              if(number%i == 0){
                  return false; //number is divisible so its not prime
              }
          }
          return true; //number is prime now
      }
  }
  </code></pre>
  
  <p>But, what I would like it to do is ask for a number, let us take 10 and then print the first 10 prime numbers,  I have tried to see if I could find a way, but I do not know how to since I have not used java that much. I hope that you can and will help me. </p>