erweiterung
This commit is contained in:
10
BeispielRekusion/BeispielRekusion.csproj
Normal file
10
BeispielRekusion/BeispielRekusion.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
33
BeispielRekusion/Program.cs
Normal file
33
BeispielRekusion/Program.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.ExceptionServices;
|
||||
|
||||
namespace BeispielRekusion
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine(FatultaetRekursiv(16062));
|
||||
}
|
||||
static long FakultaetIterativ(int n)
|
||||
{
|
||||
long ergebnis = 1;
|
||||
for (int i = 1; i <= n; i++)
|
||||
{
|
||||
ergebnis = ergebnis * i;
|
||||
}
|
||||
return ergebnis;
|
||||
}
|
||||
static ulong FatultaetRekursiv(ulong n)
|
||||
{
|
||||
if (n == 1)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return n * FatultaetRekursiv(n-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user