| 
                        123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 | 
                        - <?php
 - 
 - namespace App\Commands;
 - 
 - use Illuminate\Console\Scheduling\Schedule;
 - use LaravelZero\Framework\Commands\Command;
 - 
 - class Factorial extends Command
 - {
 -     /**
 -      * The signature of the command.
 -      *
 -      * @var string
 -      */
 -     protected $signature = 'factorial {numero} {--grafica}';
 - 
 -     /**
 -      * The description of the command.
 -      *
 -      * @var string
 -      */
 -     protected $description = 'este comando es para calcular el factorial de un numero';
 - 
 -     private function factorial(int $numero, bool $operaciones = false): int
 -     {
 -         $factorial=1;
 -         $cadena = "";
 -         for ($i = $numero; $i > 0; $i--)
 -         {
 -             $cadena .= $factorial. ' * '.$i;
 -             $factorial = $factorial * $i;
 -             $cadena .= ' = '.$factorial."\n";
 -         }
 -         if ($operaciones)
 -             $this->line($cadena);
 -         return $factorial;
 -     }
 - 
 -     /*
 -     private static long factorial(int n1) {
 - 		long miNum = 1;
 - 		for(int i=1;i<=n1;i++) {
 - 			miNum*=i;
 - 		}
 - 		return miNum;
 - 	}
 - 
 -     def factorial(num):
 -     if num > 0:
 -         # Doing the factorial using recursion
 -         return int(num*factorial(num-1))
 -     else:
 -         return 1
 - 
 - 
 -         public static void multiplicar(int iTabla, int iNumero){
 - 
 - 	if (iNumero>1)
 - 		multiplicar(iTabla,iNumero-1);
 - 
 - 	System.out.println(iTabla + "x" + iNumero + "=" + iTabla*iNumero);
 - }
 -     */
 - 
 -     private function tablaMultiplicar($tabla, $numero){
 -         if ($numero > 1)
 -             $this->tablaMultiplicar($tabla, $numero-1);
 -         $this->line("{$tabla} X {$numero} = ".$tabla*$numero);
 -     }
 - 
 -     private function factorialRecursivo(int $numero, bool $operaciones = false): int
 -     {
 -         if ($numero > 0) {
 -             return $numero*$this->factorialRecursivo($numero-1);
 -         }
 -         else
 -             return 1;
 -     }
 - 
 -     /**
 -      * Execute the console command.
 -      *
 -      * @return mixed
 -      */
 -     public function handle()
 -     {
 -         $this->title('Calculo de factorial');
 -         $this->info('
 -             El factorial de un entero positivo n, el factorial de n o n
 -             factorial se define en principio como el producto de todos los números
 -             enteros positivos desde 1 hasta n.
 -         ');
 -         $factorial = $this->factorialRecursivo($this->argument('numero'), $this->option('grafica'));
 -         $this->line("El numero factorial es el siguiente = {$factorial}");
 -         $this->line("Su tabla de multiplicar es:");
 -         $this->tablaMultiplicar($this->argument('numero'), 10);
 - 
 -     }
 - 
 -     /**
 -      * Define the command's schedule.
 -      *
 -      * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
 -      * @return void
 -      */
 -     public function schedule(Schedule $schedule): void
 -     {
 -         // $schedule->command(static::class)->everyMinute();
 -     }
 - }
 
 
  |