Solved

# Working out factorial positive integer

Posted on 2003-11-20

i need to work out the factorial of a positive integer. ie the number multiplied by all the integers smaller than it down to 1. eg "5" = 5*4*3*2*1 = 120.

i also need to incorporate a test harness.

the code i have written works out teh factors of any given number but i am not sure off how to work out the final answer. ie. how to multiply them together.

#include<stdio.h>

void main (void){

int num,x;

void factorial(int);

printf("Please enter an integer: ");

scanf("%d", &num);

fflush(stdin);

for(x=1; x<num; x++)

factorial (x);

}

void factorial (int x){

printf("x = %d\n", x);

help would b much appreciated. cheers.