How to print Floyd’s triangle in MATLAB

MATLAB
x
25
%{
1
2 3
4 5 6
7 8 9 10
%}
clc; clear all; close all;
n = input('Enter the number of rows: ');
for i = 1:n % for rows
for j = 1:i % for columns
fprintf('%d ',j+(i-1)*(i-2)/2); % print the numbers in Floyd's triangle pattern
end
🤖 Code Explanation
The code written in MATLAB is for printing numbers in Floyd's triangle pattern.

More problems solved in MATLAB




















