! Cálculo del factorial recursivo
  ! Calcula el factorial de un número
  !
  ! jbgarcia@uvigo.es


  object CalculaFactorial : ConsoleApplication

    method + calculaFactorial ( n )
      reference toret = n

      ! Caso base
      n.isEqualTo ( 1 )
      jumpOnTrueTo fin

      ! Caso regular
      toret = toret.multiplyBy ( __this.calculaFactorial ( n.substract ( 1 ) ) )

      :fin
      return toret
    endMethod

    method + doIt ( )
      reference x

      System.console.write ( "Cálculo del factorial recursivo" )
      System.console.lf ( )

      System.console.write ( "Número: " )
      x = Int.parseString ( System.console.read ( ) )
      System.console.lf ( )

      System.console.write ( "El factorial es: " )
      System.console.write ( __this.calculaFactorial ( x ) )
      System.console.lf ( )
      return
    endMethod

  endObject