title: Armstrong number logic error
body: <p>Here I've code to print armstrong numbers until some particular range. But this programs doesnt prints all the numbers within the range. It just prints armstrong number within range of 1000. Whats wrong in this code?</p>
  
  <pre><code>public static void main(String[] args) {
      long N, temp, sum = 0;
      Scanner ip = new Scanner(System.in);
      System.out.print("Enter the range: ");
      N = ip.nextLong();
      for (long i = 1; i &lt; N; i++) {
          temp = i;
          while (temp &gt; 0) {
              long rem = temp % 10;
              sum = sum + (rem * rem * rem);
              temp = temp / 10;
          }
          if (sum == i) {
              System.out.println(" " + i);
          }
          sum = 0;
      }
      ip.close();
  }
  </code></pre>
  
  <p>when the input is 100000 it just prints</p>
  
  <pre><code>Enter the range: 100000
   1
   153
   370
   371
   407
  </code></pre>