Definiertheit der Fakultätsfunktion
Bearbeiten
Im folgenden Beispiel wird die Definiertheit anhand des Beispiels der Fakultät gezeigt.
x
!
:=
x
∗
(
x
−
1
)
∗
(
x
−
2
)
.
.
.2
∗
1
f
u
e
r
x
>
0
{\displaystyle x!:=x*(x-1)*(x-2)...2*1~fuer~x>0}
Es ist bekannt, dass
0
!
:=
1
{\displaystyle 0!:=1}
und
x
!
:=
x
∗
(
x
−
1
)
!
{\displaystyle x!:=x*(x-1)!}
.
Für negative Werte sind Fakultäten nicht definiert.
1.Lösung
f
a
c
(
x
)
:=
i
f
(
x
==
0
)
t
h
e
n
1
e
l
s
e
x
∗
f
a
c
(
x
−
1
)
{\displaystyle fac(x):=if~(x==0)~then~1~else~x*fac(x-1)}
Das bedeutet:
f
a
c
(
x
)
:=
{
x
!
f
a
l
l
s
x
≥
0
⊥
s
o
n
s
t
{\displaystyle fac(x):=\left\{{\begin{array}{ll}x!&falls~x\geq 0\\\bot &sonst\end{array}}\right.}
2.Lösung
f
a
c
(
x
)
:=
i
f
(
x
≤
0
)
t
h
e
n
1
e
l
s
e
x
∗
f
a
c
(
x
−
1
)
{\displaystyle fac(x):=if~(x\leq 0)~then~1~else~x*fac(x-1)}
Das bedeutet:
f
a
c
(
x
)
:=
{
x
!
f
a
l
l
s
x
≥
0
1
s
o
n
s
t
{\displaystyle fac(x):=\left\{{\begin{array}{ll}x!&falls~x\geq 0\\1&sonst\end{array}}\right.}
Da die Vorlesungsinhalte auf dem Buch Algorithmen und Datenstrukturen: Eine Einführung mit Java von Gunter Saake und Kai-Uwe Sattler aufbauen, empfiehlt sich dieses Buch um das hier vorgestellte Wissen zu vertiefen. Die auf dieser Seite behandelten Inhalte sind in Kapitel 3.2.6 zu finden.