Untitled

 avatar
unknown
java
a year ago
418 B
4
Indexable
import java.util.Scanner;

public class P1 {
	public static int Sol(int n) {
		int sumValue = 0;
		for (int i = 1; i < n; i++) {
			sumValue += i;
			if (sumValue >= n) {
				sumValue = i - 1;
				break;
			}

		}

		return sumValue;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		System.out.println(Sol(n));
//		Sol(n);

	}
}
Editor is loading...
Leave a Comment