1+2+...+n>=max问题的求解
package Hello; public class Demo1 { public static void main(String args[]) { long sum = 0, i = 1, N = 0, max = 1931918; while(true) { sum = sum + i; if(sum > max) { N = i-1; break; } i ++; } System.out.println("满足1+2+...+n <= "+max+"的最大整数是:"+ N); } }