Advertisement
warcislawtez

Untitled

Feb 21st, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. clc;
  2. clear;
  3. disp('Zad. 15')
  4. disp('Program liczy: 1^2 + 2^2 + 3^2 + ... + n^2 , założenie: n jest liczbą naturalną')
  5. n=input('Podaj wartość n: ');
  6. while n<0 || n~=round(n)
  7. n=input('Zła wartość liczby. Podaj ponownie: ');
  8. end
  9. wynik=0;
  10. for a=1:n;
  11. wynik=wynik+(a^2);
  12. end
  13. disp(['Wynik = ',num2str(wynik)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement