/*
   Autor(s)      : Jordi Ferrer Plana
   e-mail        : jferrerp@eia.udg.es
   Branch        : Estructura i Tecnologia de Computadors (ETIS/ETIG)

   Working Group : Departament d'Electrōnica, Informātica i Automātica
   Project       : Exemples

   Homepage      : http://eia.udg.es/etc/

   Module        : Cālcul del factorial recursivament en C.

   File          : fact.c
   Date          : 16/05/2003 - 16/05/2003
   Encoding      : ISO-8859-1 (Latin-1)

   Compiler      : gcc >= 2.95.3
   Libraries     : -

   Notes         : - Realitza el factorial d'un valor d'entrada utilitzant
                     una funciķ recursiva.

  ----------------------------------------------------------------------------

   Copyright (C) 2002-2003, Jordi Ferrer Plana

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License   
   as published by the Free Software Foundation; either version 2
   of the License, or (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

   See the GNU General Public License (http://www.gnu.org/copyleft/)
   for more details.
 
  ----------------------------------------------------------------------------
*/


int Fact ( int n )                 /* Funciķ recursiva factorial */
{
   if ( n < 1 )                    /* Calcular si cas directe o cas recursiu */
      return 1;                    /* Cas directe: Fact ( 0 ) = 1 */
   else                            /* Cas recursiu: */
      return Fact ( n - 1 ) * n;   /*   Fact ( n ) = Fact ( n - 1 ) * n */
}

int main ( void )
{
   /* Cridar a printf calculant el resultat del factorial de 10 */
   printf ( "El factorial de 10 es %d\n", Fact ( 10 ) );

   return 0;
}

