~cpp #include <stdio.h> void min_int_sum(void); int main(void) { min_int_sum(); return 0; } void min_int_sum() { int n = 1; while ((n * n + n) / 2 <= 3000) n++; printf("n = %d, sum = %dn", n, (n * n + n) / 2); }
~cpp #include <stdio.h> void min_int_sum(void); int main(void) { min_int_sum(); return 0; } void min_int_sum() { int n = 0, sum = 0; while (sum <= 3000) { n++; sum += n; } printf("n = %d, sum = %dn", n, sum); }