Untitled
Anonymous
plain_text
07/17/2021 2:42 AM
468 B
100
Indexable
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int sum = 0;
int res = 0;
for(int i = 1; i <= n; i++) {
sum += i;
if(sum > n) {
res = i - 1;
break;
}
}
System.out.println(res);
}
}
Editor is loading...