Summary

This document contains C# code to calculate the factorial of a given integer. It takes the integer from the user's input, calculates the factorial through a loop and prints the result to the console.

Full Transcript

```C# using System; namespace VT05_Practica { public class Program { static void Main() { // -- Pedir un número Console.WriteLine("Introduce un número: "); int numero = Int32.Parse(Console.ReadLine()); // -- Calcular factorial // -- numero = 6 --> 1*2*3*4*...

```C# using System; namespace VT05_Practica { public class Program { static void Main() { // -- Pedir un número Console.WriteLine("Introduce un número: "); int numero = Int32.Parse(Console.ReadLine()); // -- Calcular factorial // -- numero = 6 --> 1*2*3*4*5*6 int resultado = 1; for (int i = 1; i <= numero; i++) { resultado = resultado * i; } // -- Imprimir el resultado Console.WriteLine(resultado); } } } ``` CALCULAR EL FACTORIAL DE UN NUMERO The document shows C# code that calculates the factorial of a number. The code reads a number from the console, then calculates the factorial using a loop that iterates from 1 to the entered number, multiplying the result by the loop counter. The final result it's printed to the console after the loop finishes.

Use Quizgecko on...
Browser
Browser