having trouble with for loops
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Joseph
am 13 Feb. 2014
Beantwortet: Alonso Mukendi Kalonji
am 29 Okt. 2022
Having Trouble...
'Sum of N^2 with N = 1 to 1,000 using a for loop'
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (2)
Roger Stafford
am 13 Feb. 2014
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 Kommentare
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!