Problem 42935. Sums of cubes and squares of sums

Given the positive integers 1:n, can you:

1. Compute twice the sum of the cubes of those numbers.
2. Subtract the square of the sum of those numbers.
3. Divide that result by n/2. 

So, for n = 3, we might compute a result like this:

((1^3 + 2^3 + 3^3)*2 - (1 + 2 + 3)^2)/(3/2)
ans =
    24

Yes, you probably can do all of this, but be careful on this problem, as n may be somewhat large, and I am expecting to see the correct result, not just an approximate value. Remember there are always different ways one may solve a problem.

I point out the Project Euler reference because PE problem 6 is what made me think of this problem, and because the test cases will push the limits of what you can do if you are not careful.

Solution Stats

16.66% Correct | 83.34% Incorrect
Last Solution submitted on Dec 16, 2024

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers263

Suggested Problems

More from this Author4

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!