using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp2 { public static class Intkiterjesztesek { public static int Factorial(this int szam) { if (szam < 0) { throw new ArgumentException("A negatív számoknak nincs faktoriálisa"); } if (szam == 0 || szam == 1) { return 1; } int result = 1; for (int i = 2; i <= szam; ++i) { result *= i; } return result; } } class Program { static void Main(string[] args) { int szam = 5; int factorial = szam.Factorial(); Console.WriteLine($"{szam}! = {factorial}"); } } }