Skip to main content
1 of 8
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384

#Java 8, 151 bytes

n->{int r=0,i=10000;for(;i-->0;r+=c(i)<n?1:0);return r;}int c(int n){int i=(int)Math.sqrt(n);for(;i>0;i--)if(n%i<1){i=n/i-i;break;}return i<0?-i:i;}

Can definitely be golfed by not having a separate method and merging the two for-loops, but still have to figure this out. This will do for now.

Explanation:

Try it here.

n->{             // Method with integer as parameter and return-type
  int r=0,       //  Result-integer
      i=10000;   //  Index-integer starting at 10,000
  for(;x-->0;    //  Loop from 10,000 down to 0
    r+=c(x)<n?   //   If the MaxMin-Divisor Pair's difference is lower than the input:
      1          //    Add 1 to the result
     :           //   Else:
      0          //    Leave the result the same
  );             //  End of loop
  return r;      //  Return the result
}                // End of method

int c(int n){    // Separate method with integer as parameter and return-type
  int i=(int)Math.sqrt(n);
                 //  Index-integer starting at the square-root of the input
  for(;i>0;i--)  //  Loop down to 0
    if(n%i<1){   //   If the input is divisible by the current index-integer
      i=n/i-i;   //    Subtract the MaxMin Divisor pair from each other
      break;     //    And leave the loop
    }
                 //  End of loop (implicit / single-line body)
  return i<0?    //  If the resulting MaxMin Divisor was negative:
    -i           //   Return its positive equivalent
   :             //  Else (it was already positive)
    i;           //   Simply return it
}                // End of separated method
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384