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

clear; clc;

n = 10;
nfact = 1;

while n>1
  nfact = nfact * n;
  n = n -1;
end