What is an Armstrong Number

Definition

In number theory, a narcissistic number or “Armstrong number” is a number where in a given number base b is a number that is the sum of its own digits each raised to the power of the number of digits. This definition is way more complicated than it actually is. Check out this example

Example for an Armstrong number

Armstrong Number Example

The first image shows an Armstrong number.
The second image shows a number that is not an Armstrong number.

List of Armstrong numbers between 1 and 100000

  • 1, 2, 3, 4, 5, 6, 7, 8, 9, 153, 370, 371, 407, 1634, 8208, 9474, 54748

The largest known Armstrong number is

115,132,219,018,763,992,565,095,597,973,971,522,401

C# Program to check if a number is an Armstrong number

Project Setup

  • Create a new project in the visual studio 2019.
  • Select the C# Project Template – [ Console App .NET Framework]
  • Configure your new project with a name “Armstrong”, set location, and solution file with a name “Armstrong”.
  • When a new project created automatically generated with the basic structure of the program.

Code

Copy to Clipboard

Advanced Version of a C# Programm for the Amstrong Number

Here we add few code lines to see what actually happens.

Copy to Clipboard

Summary for Armstrong Number with C#

Now you see how the Armstrong number works, and how you can write a C# Programm that checks if a given number is an Armstrong Number, or not.