You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Übungen_LF6_WinFormanwendung
|
|
|
|
|
{
|
|
|
|
|
class class_übungen
|
|
|
|
|
{
|
|
|
|
|
public static double max2(double a, double b)
|
|
|
|
|
{
|
|
|
|
|
double max = 0;
|
|
|
|
|
if (a > b)
|
|
|
|
|
max = a;
|
|
|
|
|
else
|
|
|
|
|
max = b;
|
|
|
|
|
|
|
|
|
|
return max;
|
|
|
|
|
}
|
|
|
|
|
public static double max3(double a, double b, double c)
|
|
|
|
|
{
|
|
|
|
|
double max = 0;
|
|
|
|
|
|
|
|
|
|
max = max2(a, b);
|
|
|
|
|
max = max2(max, c);
|
|
|
|
|
|
|
|
|
|
return max;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool istTeilerVon(int x, int d)
|
|
|
|
|
{
|
|
|
|
|
bool teilbar = false;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (x % d == 0)
|
|
|
|
|
teilbar = true;
|
|
|
|
|
else
|
|
|
|
|
teilbar = false;
|
|
|
|
|
|
|
|
|
|
return teilbar;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int qsum(int i)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
string pufferlaenge = i.ToString();
|
|
|
|
|
int querSumme = 0;
|
|
|
|
|
|
|
|
|
|
int laenge = pufferlaenge.Length;
|
|
|
|
|
|
|
|
|
|
for (int count = laenge; count > 0; count--)
|
|
|
|
|
querSumme += Convert.ToInt32(pufferlaenge.Substring(count));
|
|
|
|
|
|
|
|
|
|
return querSumme;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool istPrim(int i)
|
|
|
|
|
{
|
|
|
|
|
bool prim = false;
|
|
|
|
|
int countDivisions = 0;
|
|
|
|
|
|
|
|
|
|
for (int counter = 1; counter == i/2; counter++)
|
|
|
|
|
{
|
|
|
|
|
if (i % counter == 0)
|
|
|
|
|
countDivisions++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (countDivisions <= 2)
|
|
|
|
|
{
|
|
|
|
|
prim = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
prim = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return prim;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public bool istPrim(int anfang, int ende)
|
|
|
|
|
{
|
|
|
|
|
bool prim = false;
|
|
|
|
|
int countDivisions = 0;
|
|
|
|
|
|
|
|
|
|
for (int counter = anfang; counter == ende / 2; counter++)
|
|
|
|
|
{
|
|
|
|
|
if (anfang % counter == 0)
|
|
|
|
|
countDivisions++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (countDivisions <= 2)
|
|
|
|
|
{
|
|
|
|
|
prim = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
prim = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return prim;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int euclid_old(int a, int b)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (a == 0)
|
|
|
|
|
return b;
|
|
|
|
|
else
|
|
|
|
|
while (b != 0)
|
|
|
|
|
{
|
|
|
|
|
if (a > b)
|
|
|
|
|
a = a - b;
|
|
|
|
|
else
|
|
|
|
|
b = b - a;
|
|
|
|
|
}
|
|
|
|
|
return a;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|