Strong Number in Windows Store App

In this article I explain Strong Numbers in Windows Store app.

First of all let us understand what a Strong Number is. A number is called a Strong Number if the sum of the factorials of each of its digits is equal to the number itself. In other words, the sum of the factorials of digits of a number is equal to the original number.

Example: Number 145=1!+4!+5!

In this article I explain how to create a Strong Number application in a Windows Store app.

Use the following procedure to create the Strong Number app.

Step 1

First you must create a New Window Store Application, as in:

  • Open Visual Studio 2012
  • "File" -> "New" -> "Project..."
  • Choose Template: "Visual C#" -> "Window Store app"
  • "Blank App (XAML)", then rename the application


Step 2

Write the following XAML code in "Mainpage.Xaml" (that is available in Solution Explorer):









    <Grid Background="Blue">


            <RowDefinition Height="38*"/>

            <RowDefinition Height="23*"/>

            <RowDefinition Height="31*"/>

            <RowDefinition Height="32*"/>

            <RowDefinition Height="63*"/>

            <RowDefinition Height="581*"/>



            <ColumnDefinition Width="161*"/>

            <ColumnDefinition Width="303*"/>

            <ColumnDefinition Width="902*"/>


        <TextBlock Text="Check Number is Strong Number or not" FontFamily="Arial" FontSize="14" FontWeight="ExtraBold" Foreground="Red" Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="2"></TextBlock>

        <TextBlock Text="Enter Number:" FontFamily="Arial" FontSize="15" FontWeight="ExtraBold" Foreground="Red" Grid.Column="1" Grid.Row="2"></TextBlock>

        <TextBox x:Name="Textbox1" Width="150" Height="32" VerticalAlignment="Top" Grid.Column="2" Grid.Row="2" HorizontalAlignment="Left" Grid.RowSpan="2" />

        <TextBlock Text="Number is:" FontFamily="Arial" FontSize="15" FontWeight="ExtraBold" Foreground="Red" Grid.Column="1" Grid.Row="3"></TextBlock>

        <TextBlock x:Name="text2" FontFamily="Arial" FontSize="15" FontWeight="ExtraBold" Foreground="Red" Grid.Column="2" Grid.Row="3"></TextBlock>

        <Button Content="Click" Click="Button1_click" Grid.Column="2" Grid.Row="4" FontSize="15" Foreground="Red" Background="Yellow" Width="137" Height="38" Margin="0,15,0,10" ></Button>



Step 3

Now write the following C# code for the button within "Mainpage.Xaml.cs":

using System;

using System.Collections.Generic;

using System.IO;

using System.Linq;

using Windows.Foundation;

using Windows.Foundation.Collections;

using Windows.UI.Xaml;

using Windows.UI.Xaml.Controls;

using Windows.UI.Xaml.Controls.Primitives;

using Windows.UI.Xaml.Data;

using Windows.UI.Xaml.Input;

using Windows.UI.Xaml.Media;

using Windows.UI.Xaml.Navigation; 

namespace Strong_Number_app


    public sealed partial class MainPage : Page


        public MainPage()




        protected override void OnNavigatedTo(NavigationEventArgs e)



       private void Button1_click(object sender, RoutedEventArgs e)


           int num = Convert.ToInt32(Textbox1.Text);

           int sum = 0, num1;

           num1 = num;

            while (num>0)


               int fact = 1;

               int r=num %10;

                for (int j = 1; j <= r; j++)


                    fact = fact * j;


                sum = sum + fact;

                num = num / 10;


            if (sum == num1)


                text2.Text = "Strong Number";




                text2.Text = "Not Strong Number";






Step 4

Now Run your app.