I'm going to write this in C/C++, because that's how I am.
Given an int (integer) value N, we want to find the product of all values 1..N (inclusive). We can do this, simply, by doing it 'backwards' from N..1, like so:
int N = ...;
.
.
.
int factorial = 1;
while (N > 0) {
factorial = factorial * N;
N = N - 1;
}
Actually, in C/C++ we can write the loop even more concisely:
while (N > 0) {
factorial *= N--;
}