Find the largest number of distinct integers that sum to n The Task

Given an input positive integer n (from 1 to your language's limit, inclusively), return or output the maximum number of distinct positive integers that sum to n.

Test Cases

Let f define a valid function according to the task:

The sequence for f, starting at 1:

1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, ...


As a larger test case:

&gt;&gt;&gt; f(1000000000) // Might not be feasible with brute-forcers
44720


Test Code

For any test cases not explicitly given, the output of your code should match the result of the following:



public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        System.out.println((int) Math.floor(Math.sqrt(2*x + 1./4) - 1./2));
    }
}


Try it online!
05AB1E, 4 bytes

ÅTg&lt;


Try it online!

Perfect tool for the job.

ÅT yields the list of Åll Triangular numbers up to and including N (unfortunately includes 0 too, otherwise it would be 3 bytes), g&lt; gets the length and decrements it.