How do i write a script that will print the following multiplication table 1; 2 4; 3 6 9; 4 8 12 16; 5 10 15 20 25

14 次查看(过去 30 天)
How do i write a script that will print the following multiplication table 1;2 4;3 6 9; 4 8 12 16; 5 10 15 20 25

回答(4 个)

asma sarouji
asma sarouji 2018-11-2

Guillaume
Guillaume 2015-4-30
This looks like homework (and really easy at that), so here is a very simple solution that probably wouldn't be accepted for homework:
arrayfun(@(x) (1:x)*x, 1:5, 'UniformOutput', false); celldisp(ans)

PaulS
PaulS 2015-4-30
编辑:Walter Roberson 2021-8-20
n=5
A=zeros(n)
for i=1:n
for j =1:n
if j<=i
A(i,j)=i*j
end
end
end

Tony Nguyen
Tony Nguyen 2021-8-15
clc;
clear all;
for i = 1:5
fprintf('%4d',i*[1:i])
fprintf('\n')
end

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by