Factorial using Addition
问题 I am attempting to create a C code that finds the factorial of a integer so that I may convert my code to assembly language. My code seems to 'multiply' the second integer twice. i.e. 5*4*4*3... I cannot seem to find out why. Help please! #define N 5 int main() { int j = 0; int i = 0; int num1 = N; int num2 = N - 1; int sum = 0; while (num2 != 0) { while (j < num2) { sum += num1; j++; } j = 0; printf("%d\n", sum); printf("--------------\n"); --num2; num1 = sum; } printf("--->%d", sum); }