title: Finding Odd Numbers of Divisors
body: <p>I am trying to solve a problem that is on <a href="http://www.spoj.com/problems/ODDDIV/" rel="nofollow">this page</a>. I think I have solved it as it gives me correct results but when I submit the code in the web page it says wrong answer. I don't understand where's my mistake. Could you please help me?</p>
  
  <pre><code>class Exercise 
  {
      BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
      int divisor;
      int count = 0;
      int numbers = 0;
      int low;
      int high;
  
      // Get the input of the user
      public void getInput() throws IOException 
      {
          System.out.println("Please enter k, low and high");
          String line1 = input.readLine();
          String line2 = input.readLine();
          String line3 = input.readLine();
  
          divisor = Integer.parseInt(line1);
          low = Integer.parseInt(line2);
          high = Integer.parseInt(line3);
      }
  
      // Finding number of odd divisors for each number
      public void calculate()
      {
          if ((divisor % 2 != 0)) {
              for (int k = low; k &lt;= high; k++) {
                  count = 0;
                  for (int j = 1; j &lt;= k; j++) {
                      if (k % j == 0) {
                          count++;
                      }   
                  }
                  if (count == divisor) {
                      numbers++;
                  }
              }
              System.out.println(numbers);
          }
          else
              System.out.println("Sorry. The divisor should be an odd number. Please try again.");
      }
  
      public static void main(String[] args)
      {
          Exercise obj = new Exercise();
          try {
              obj.getInput();
              obj.calculate();
          }
          catch(Exception e) {
              return;
          }
      }   
  }
  </code></pre>