Aufgabe 4: > restart; with(numtheory); > FZ := proc (a::nonnegint) local F, n; if isprime(a) = true then print(a ist prim) else F := divisors(a); n := nops(F); print(AnzahlTeiler = n); print(SummeTeiler = sum(op(i, F), i = 1 .. n)) end if end proc; > FZ(17); 17 ist prim > FZ(124); AnzahlTeiler = 6 SummeTeiler = 224 > Aufgabe 5: > with(GraphTheory); > Wenn man die Funktion 'IsBipartite' verwendet, geht es recht schnell: > GP := proc (G) if IsBipartite(G, 'Partition') = true then print(Partition) else print("Fehler bei der Eingabe") end if end proc; > ` Beispiel: > K32 := CompleteGraph(3, 2); > GP(K32); [[1, 2, 3], [4, 5]] > Ohne Verwendung der Funktion 'IsBipartite': > GP2 := proc (G) local T, S, v, w; T := {}; S := {}; v := op(1, Vertices(G)); T := `union`(T, {v}); for w in Vertices(G) do if `mod`(Distance(G, v, w), 2) = 1 then S := `union`(S, {w}) else T := `union`(T, {w}) end if end do; print(T); print(S) end proc; > Beispiel: > GP2(K32); {1, 2, 3} {4, 5} >