%% SL 5
clear;
N = 6;
F = 1;
for n = 1:N
    F = F*n;
end
%
prod(1:N)
%
factorial(N)

%% SL 9
clear
N = 100;
s = 0;
n = 0;
while n < N
    n = n + 1;
    s = s + n;
end

%
s2 = sum(1:100)

%% SL 13
mRows = 100;
nCols = 20;
A = zeros(mRows, nCols);
for m = 1:mRows
    for n = 1:nCols
        A(m, n) = (m*n)/4 + m/(2*n);
    end
end
pcolor(A)

%% SL 15
close all; clear;
N = 101;
om0 = 2*pi;
x = linspace(-pi/2, pi/2, N);
t = linspace(0, 4*pi, N);
I0 = cos(x);
for n = 1:N
    I = I0*exp(1j*om0*t(n));
    figure(1);
    plot(x, real(I));
    axis([x(1) x(end) -1 1]);
    pause(0.1);
end

%% SL 23
clear, clc
nStudents = 40;
points = randi(100, nStudents, 1);
A = 0; B = 0; C = 0;
for iS = 1:nStudents
    if points(iS) >= 80
        A = A+1;
    elseif points(iS) >= 35
        B = B+1;
    else
        C = C+1;
    end
end

%
A2 = sum(points >= 80);
B2 = sum(points >= 35 & points < 80);
C2 = sum(points < 35);

%% SL 26
grade = 4;
switch grade
    case 1
        reward = 1000;
    case 2
        reward = 500;
    case 3
        reward = 200;
    case 4
        reward = 50;
    otherwise
        reward = 0;
end
disp(reward)

%
grade = 4;
reward = [1000 500 200 50 0];
reward(grade == 1:5)