title: Maximum Remainder
body: <p>Maximum remainder </p>
  
  <p>You are given a number N. Write a program to find a natural number that is smaller than N such that N gives the highest remainder when divided by that number. 
  If there is more than one such number, print the smallest one. </p>
  
  <p>Can anyone help I think I'm missing something like if 2 numbers will have same reaminders my code would overwrite the minDivisor to the upper value</p>
  
  <pre><code>static int findRemainder(int num){
      int maxRemainder=0;
      int minDivisor=0
      int answer=0;
  
      for(int i = 1; i&lt;num; i++){
          if(maxRemainder &lt;= (num % i)) {
              maxRemainder = num % i;
              if(minDivisor &lt; i &amp;&amp; maxRemainder == num%i) {
  
              } else {
                  minDivisor = i;
              }
          }
          return minDivisor;
      }
  }
  </code></pre>