Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.school;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- int A = in.nextInt(), sum = 0, counter = 0;
- for (int step = 1; sum <= A; step ++) { // Увеличиваем ограничитель значения
- for (int plus = 1; plus <= step; plus ++) sum += plus; // Суммируем слагаемые
- counter += 1; // Увеличиваем счетчик
- }
- System.out.println(counter - 1);
- }
- }
Add Comment
Please, Sign In to add comment