time complexity of the following function

What is the time complexity of the following function?
F(n)
{
    r = 0;
    for i = 1 to n
        for j = i+1 to n
            for k = 1 to j
                r = r + 1;
    return(r);
}

as per my solution

i=1  2                p

j=n-1  n-2     n-p

k=n-1 n-2    n-p

n-(1+2+3+....+p)

n-n(n+1)/2

that O(n^2)

1Comment
kiran ingole @kiraningole 7 Mar 2016 12:41 pm

i got to know answer but not sure

i 1 2 3                   p

j (n-1)time  (n-2)time    (n-3)time                                                n-p time

k (n-1)^2    (n-2)^2                                                                      (n-p)^2

=n^2-2np+p2

p is sum of natural no

by second term n*n*(n+1)/2

that O(n^3)

 

please provide answer