hmi95 / fibonacci

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

(German version below)

Fibonacci exercise

Fibonacci sequence

The Fibonacci sequence is the infinite sequence of natural numbers that begins with the number 1 twice and in which each additional number in the sequence is the sum of the two numbers preceding it.

Sometimes the sequence also begins with the numbers 0 and 1. Here we use the definition in which the first and second number of the Fibonacci sequence is the number 1.

Practice task

Given a console application in each programming language (currently in C#, C++, Java and Python), which outputs the first three numbers of the Fibonacci sequence.

Based on this solution, the following changes are to be made one after the other and the result presented in each case (program and code).

  1. Extend the given solution so that the first 22 numbers of the Fibonacci sequence are output.
  2. Add blank lines (select a variant)
    1. Extend the solution from 1. so that whenever the current number in the sequence has one more digit than the previous one, an additional blank line is output before the current number.
    2. Extend the solution from 1. so that an additional blank line is output after every 10 numbers in the Fibonacci sequence.
  3. Extend the solution from 2. so that 50 Fibonacci numbers are now output.

Fibonacci Aufgabe

Fibonacci-Folge

Die Fibonacci-Folge ist die unendliche Folge natürlicher Zahlen, die mit zweimal der Zahl 1 beginnt, und bei der jede weitere Zahl der Folge die Summe der beiden ihr vorangehenden Zahlen ist.

Teilweise wird die Folge auch mit den Zahlen 0 und 1 begonnen. Wir verwenden hier die Definition, bei der die erste und zweite Zahl der Fibonacci-Folge die Zahl 1 ist.

Aufgabe

Gegeben ist in jeder Programmiersprache (aktuell in C#, C++, Java und Python) jeweils eine Konsolenanwendung, welche die ersten drei Zahlen der Fibonacci-Folge ausgibt.

Ausgehend von dieser Lösung sind nacheinander folgende Änderungen durchzuführen und jeweils das Ergebnis vorzuführen (Programm und Code).

  1. Die gegeben Lösung so erweitern, dass die ersten 22 Zahlen der Fibonacci-Folge ausgeben werden.
  2. Leerzeilen hinzufügen (wähle eine Variante aus)
    1. Die Lösung aus 1. so erweitern, dass immer dann, wenn die aktuelle Zahl aus der Folge eine Stelle mehr hat als die vorige, vor der aktuellen Zahl eine zusätzliche Leerzeile ausgegeben wird.
    2. Die Lösung aus 1. so erweitern, dass nach jeweils 10 Zahlen der Fibonacci-Folge eine zusätzliche Leezeile ausgegeben wird.
  3. Die Lösung aus 2. erweitern, sodass jetzt 50 Fibonacci Zahlen ausgeben werden.

About


Languages

Language:Java 35.6%Language:C++ 34.5%Language:C# 18.9%Language:Python 11.0%