// fact_recursive.c - recursive solution for factcalculation

#include <stdio.h>

unsigned fact(unsigned num);

//------------------------------------------------------------
int main()
{
  unsigned num = 0;

  printf("Please enter a positive number: ");
  scanf("%u",&num);
  printf("%u! is %u\n",num,fact(num));
  return(0);
}

//------------------------------------------------------------
unsigned fact(unsigned num)
{
  if (num <= 1)
    return(num);
  return(num * fact(num - 1));
}
