function r=sumofcubes(N) ans=0; for i=1:N ans=ans+i^3; end r=ans;