Added everything from Kalmar

This commit is contained in:
szabomarton
2023-12-13 11:35:33 +01:00
parent 13dc94d004
commit 40d12f5d58
146 changed files with 2165 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
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}");
}
}
}