having trouble with for loops
    3 ビュー (過去 30 日間)
  
       古いコメントを表示
    
Having Trouble...
'Sum of N^2 with N = 1 to 1,000 using a for loop'
0 件のコメント
採用された回答
その他の回答 (2 件)
  Roger Stafford
      
      
 2014 年 2 月 13 日
        Here's a way to check your answer:
 n = 1000;
 s = n*(n+1)*(2*n+1)/6;
This gives you the same value as
 s = sum((1:n).^2);
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!