Fibonacci 2.0

Using the Visual Studio integrated development environment and the C# programming language, we will develop a cross-platform mobile application to generate Fibonacci sequence numbers.

circle-info

Information

In mathematics, the Fibonacci numbers form a sequence defined recursively as follows: it starts with 0 and 1, and each subsequent term is the sum of the previous two. The first Fibonacci numbers are: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, …

Start

  1. Launch the Visual Studio integrated development environment.

  2. Create a new project: Visual C# > Cross-Platform > Mobile App (Xamarin.Forms).

  3. Name the project: Fibonacci 2.0.

MainPage.xaml

The MainPage.xaml file contains the source code for the application's user interface design and is written in XAML. Copy (Ctrl+C) and paste (Ctrl+V) the fragment below into your application

<!-- User Interface (UI): Fibonacci 2.0 -->
<StackLayout Padding="20">
        
    <!-- Title -->
    <Label Text="Fibonacci 2.0" FontSize="Large" />
        
    <!-- Limit -->
    <Label Text="Limit" />
    <Entry x:Name="boxLimit" Keyboard="Numeric" Text="1000" />
    <Button Text="Generate" Clicked="OnButtonClicked" />
        
    <!-- Numbers -->
    <ListView x:Name="boxNumbers" />
        
</StackLayout>

MainPage.xaml.cs

The MainPage.xaml.cs file contains the source code for the application's business logic and is written in C#. Copy (Ctrl+C) and paste (Ctrl+V) the fragment below into your application.

Demo

Run the application from the menu: Debug > Start Debugging or by pressing the F5 key.

Fig. 2.58 Testing the cross-platform mobile application for generating the Fibonacci sequence - Android Emulator 11 (API 30)

Last updated