I made a program which factorizes a number.

Here s the source code:



function getFactor(n)
for i = 2, n-1 do
  if n % i == 0 then
   return i;
  end
end
return -1;
end
n = io.read("Enter a number: ");
result = "" .. n .. "= ";
count = 0;
while true do
f = getFactor(n);
if (f == -1) then
  if (count == 0) then
   result = result .. n;
   break;
  else
   result = result .. "*" .. n;
   break;
  end
end
if (count == 0) then
  result = result .. f;
else
  result = result .. "*" .. f;
end
n = n / f;
count = count + 1;

end

print(result);

Hope it can help you.