Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

is narcissistic number

public static bool IsNarcissistic(int number)
{
  var sum = 0;
  var temp = number;
  var numberOfDigits = 0;
  while (temp != 0)
  {
    numberOfDigits++;
    temp /= 10;
  }

  temp = number;
  while (number > 0)
  {
    var remainder = number % 10;
    var power = (int)Math.Pow(remainder, numberOfDigits);

    sum += power;
    number /= 10;
  }

  return sum == temp;
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: elasticsearch nested aggregation in c# 
Csharp :: instantiate c# 
Csharp :: set background from C# wpf 
Csharp :: C# [] overload 
Csharp :: delete items in c# 
Csharp :: c# linq join mutiple 
Csharp :: convert bitmap to imagesource 
Csharp :: value is null to insert in c# 
Csharp :: c# code examples 
Csharp :: add one to one relationship entity framework 
Csharp :: triangle 
Csharp :: how to filter a list in c# 
Csharp :: c# list initialize 
Csharp :: c# sequential struct with fixed array size 
Csharp :: Entity framwork update parent entity added new sub entity 
Csharp :: RestRequest AdvancedResponseWriter site:stackoverflow.com 
Csharp :: building a config object in XML C# 
Csharp :: csharp-for-loop 
Csharp :: no cameras rendering unity 
Csharp :: public controller script unity 3d 
Csharp :: how to change the color of a textbox with button c# 
Csharp :: c# pull request 
Csharp :: tune off exit button wpf 
Csharp :: .net objects 
Csharp :: mysql executeScalar only if successful 
Csharp :: aps.net core mvc chek box 
Csharp :: GridViewColumn url wpf 
Csharp :: c# loop datatable column names convert to list 
Csharp :: blazor navlink change bg of current component 
Csharp :: how to make a console feedback 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =