f := function(n)
    if IsEven(n) then 
        n := Integers()!(n/2); 
    else 
        n := 3*n+1; 
    end if;
    return n;
end function;   

MyFibo := function(n)
    if n eq 0 then return 0; end if;
    if n eq 1 then return 1; end if;
    if n ge 2 then return $$(n-1) + $$(n-2); end if;
end function;


MyFibonacci := function(n)
   if n eq 0 then return 0; end if;
   if n eq 1 then return 1; end if;
   a := 0; b := 1;
   for i:=2 to n do
       c := b;
       b := a+b;
       a := c;
   end for;
   return b;
end function;


MyCR := function(a, m)
    M := 1;
    x := a[1];
    for i:=2 to #a do
        y := x;
        M := M * m[i-1];
        d,p,q := XGCD(M, m[i]);
        if d ne 1 then
            print "FEHLER: die m_i sind nicht paarweise teilerfremd.";
            return -1;
        end if;
        p := (y - a[i])*p;
        q := (y - a[i])*q;
        x := y - p*M;
    end for;
    return x mod &*m ;
end function;

MyD4 := function()
    S4 := Sym(4);
    sigma := S4 ! (1,2,3,4);
    tau := S4 ! (1,2)(3,4);
    return sub<S4 | [sigma, tau]>;
end function;
