• + 0 comments

    I'm new to this website and this confused me as to it being so simple if you know series and realize that your essentially ding a summation from k=1 to n of n^2-(n-1)^2 which is essentially equal to n^2. In other words the function is simply n^2. So to return the value with the modulus one just has to return this into just one line: ((n%1000000007)*(n%1000000007))%1000000007