Introduction
Today I am describing a very simple but interesting thing. Because we always print number from 1 to 100 using a loop. But someone asked me how to print these numbers without using a loop. Really at that time I had no idea although I proceeded to do it. I finally got the idea to use recursion (in which a method calls itself) and print the number.
Use the following procedure to implement it.
Step 1
First of all you have to create a new Windows Store Application, as in:
- Open Visual Studio 2012
- "File" -> "New" -> "Project..."
- Choose "Template" -> "Visual C#" -> "Window Store app"
- Choose "Blank App (XAML)" then rename the application

Step 2
Write the following XAML code in "Mainpage.Xaml" (that is available in Solution Explorer):
<Page
x:Class="number_app.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:number_app"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="Red">
<Grid.RowDefinitions>
<RowDefinition Height="116*"/>
<RowDefinition Height="45*"/>
<RowDefinition Height="518*"/>
<RowDefinition Height="89*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="215*"/>
<ColumnDefinition Width="479*"/>
<ColumnDefinition Width="200*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="Display Number from 1 to 100 without loop" FontSize="20" FontWeight="ExtraBold" FontFamily="Arial" Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="2"></TextBlock>

Sam HobbsPosted Feb 9, 2013, 4:35 PM
Anyone using recursion should understand the possility of stack overflow when using recursion.