code: static int isqrt(long n) {
          int x = (int) ((Math.sqrt(8.0 * n + 1.0) - 1.0) / 2.0);
          if (x * (x + 1L) / 2 > n)
              x--;
          return x;
      }
docs: /*
  Calculates (int) (Math.sqrt(8 * n + 1)-1)/2 Produces exact result for any
  long input from 0 to 0x1FFFFFFFC0000000L (2^61-2^30).