大哥   教教小弟我吧   1+2+3+4......+n <8888求最大的正整数N用JAVA来编.我真整不会了.

解决方案 »

  1.   


    public int maxN() {
      int i = 1;
      int result = 0;
      while(true) {
        result += i;
        if (result < 8888) {
          i++;
          continue;
        } else {
          break;
        }
      }
      return i;
    }
    代码没有调试,随手写的。应该能满足你的功能需要了。
      

  2.   

    (n^2+n)/2<8888 不等式求解不可以吗
      

  3.   


    return Math.floor((Math.floor(Math.sqrt(1 + 8 * 8888)) - 1) / 2);看不明白的,复习一下初一数学,哈哈。