% calculate the factorial of a number using a for loop.

clear;
clc;

n = 10;
nfact = 1;

for i=2:n
  nfact = nfact * i;
end