\documentclass{bschlangaul-aufgabe} \bLadePakete{java,mathe} \usepackage{amsmath,tikz} \usetikzlibrary{backgrounds,calc} \begin{document} \bAufgabenMetadaten{ Titel = {Fibonacci-Zahlen}, Thematik = {Fibonacci-Zahlen}, Referenz = TECH.Mehr-Adress.11-Fibonacci, RelativerPfad = Module/50_TECH/20_Mehr-Adress/Aufgabe_11-Fibonacci.tex, BearbeitungsStand = mit Lösung, Korrektheit = unbekannt, Ueberprueft = {unbekannt}, Stichwoerter = {Mehr-Adress-Befehl-Assembler}, } Die Fibonacci-Folge ist die unendliche Folge natürlicher Zahlen, die mit zweimal der Zahl 1 beginnt. Im Anschluss ergibt jeweils die Summe zweier aufeinanderfolgender Zahlen die unmittelbar danach folgende Zahl: \index{Mehr-Adress-Befehl-Assembler} \begin{displaymath} \text{fib}_{n} = \text{fib}_{n−1} + \text{fib}_{n−2} \end{displaymath} \noindent Dabei bezeichnet $n$ die $n$-te Zahl dieser Reihe. Die darin enthaltenen Zahlen heißen Fibonacci-Zahlen. Benannt ist die Folge nach Leonardo Fibonacci, der damit im Jahr 1202 das Wachstum einer Kaninchenpopulation beschrieb. Die Folge war aber schon in der Antike sowohl den Griechen als auch den Indern bekannt. Gleichmaßen lassen sich Quadratgrößen damit beschreiben: % https://texample.net/tikz/examples/fibonacci-spiral/ \begin{center} \begin{tikzpicture}[scale=0.5,transform shape] % Create some counters for holding the Fibonacci numbers \newcounter{a} \newcounter{b} \newcounter{temp} % Initialize the counters \setcounter{a}{0} \setcounter{b}{1} % The spiral will start at the origin \coordinate (0) at (0,0); % This loop defines the number of turns in the spiral. Note that we % will have to be careful not to overflow our counters or make the % spiral too large for TeX to handle. This is easy to do as the % Fibonacci sequence grows exponentially. \foreach \i in {1,...,18} { % Get the "name" of the last point on the spiral \pgfmathsetmacro{\lastpoint}{\i-1} % Compute the angle for this turn of the spiral \pgfmathsetmacro{\startangle}{mod(\i-1,4) * 90} % Draw this turn of the spiral and remember the point where we end \draw (\lastpoint) arc (\startangle : \startangle + 90 : \value{b}/10.0pt) coordinate (\i); % Compute the next Fibonacci number \setcounter{temp}{\value{b}} \addtocounter{b}{\value{a}} \setcounter{a}{\value{temp}} } % Add some framing for the spiral while at the same time not "boxing" % it in. Note that to put a square around each turn of the spiral we % could have just used the command \draw[white] (\lastpoint) % rectangle (\i); after drawing each turn in the loop above. \foreach \i in {1,3,...,17} { \pgfmathsetmacro{\lastpoint}{\i-1} \draw (\lastpoint) -| (\i); } \foreach \i in {2,4,...,16} { \pgfmathsetmacro{\lastpoint}{\i-1} \draw (\lastpoint) |- (\i); } \draw (17) -- (17 |- 18); % Add some text displaying the formula for the Fibonacci numbers \node(eq) at ($(18) + (2.5,1)$) [text width = 2cm,font=\fontsize{8}{8}\selectfont] { \begin{displaymath} f(n) = \left\{ \begin{array}{lr} 0 & \text{~~if } n = 0\\ 1 & \text{~~if } n = 1\\ f(n-1) + f(n-2) & \text{~~if } n \geq 2\\ \end{array} \right. \end{displaymath} }; \end{tikzpicture} \end{center} \noindent Die Lösung der Berechnung soll zum Schluss in $R5$ liegen. \begin{bAntwort} \bAssemblerDatei{Aufgabe_11-Fibonacci-rekursiv.mi} \bJavaDatei[firstline=3]{aufgaben/tech_info/assembler/mehr_adress/FibonacciRekursiv} \end{bAntwort} \end{document}