title: What is wrong with this small for/if loop logic?
body: <p>This code is asking for how many numbers the user will input and then it takes each of those. In the end it should return the smallest value. I know about Math.min methods, I'm just struggling with why the logic below doesn't work, it always prints the last input instead the smallest one.</p>
  
  <pre><code>import java.util.Scanner;
  
  public class Ch5_smallestValue {
  
      public static void main(String[] args) {
  
          Scanner sc = new Scanner(System.in);
          System.out.println("Input how many numbers and then input each one");
          int hMany = sc.nextInt();
  
          int firstNum = sc.nextInt();
          int smallest = firstNum;
  
          for (int i = hMany; i &gt; 1; i--){
  
             int input = sc.nextInt();
             if (smallest &lt; input){
                 smallest = input;
              } 
  
           }
  
          System.out.println("smallest = " + smallest);
  
      }
  
  }
  </code></pre>