S = [];
for i = 1:7
S(end+1) = print_s(i);
fprintf("\n");
end
fprintf("%g^2 ",sqrt(S));
function res = print_s(n)
res = 0;
for i = 1:2:(2*n-1)
res = res + i;
fprintf("%d",i);
if(i==2*n-1)
fprintf("=");
else
fprintf("+");
end
end
fprintf("%d",res);
end
Cita come
Hoi Sing Lau (2025). n square (https://it.mathworks.com/matlabcentral/fileexchange/182207-n-square), MATLAB Central File Exchange. Recuperato .
Compatibilità della release di MATLAB
Creato con
R2024b
Compatibile con qualsiasi release
Compatibilità della piattaforma
Windows macOS LinuxTag
Riconoscimenti
Ispirato da: Find numbers which can be expressed as Sum of Squares of Positive Integers
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Scopri Live Editor
Crea script con codice, output e testo formattato in un unico documento eseguibile.
| Versione | Pubblicato | Note della release | |
|---|---|---|---|
| 1.0.0 |
