Euler Problem 92

Euler Problem 92

Investigating a square digits number chain with a surprising property.


Implementacija jednostavna onako kao je u zadatku definisano:

static void Main(string[] args)
 long counter = 0;
 for (int i = 1; i < 10000000; i++)
 if (IsArrivedAt89(i))
static bool IsArrivedAt89(int n)
 if (n == 1)
  return false;
 else if (n == 89)
  return true;
 return IsArrivedAt89(Next(n));
static int Next(int n)
 int value=0;
 char[] str = n.ToString().ToArray();
 for (int i = 0; i < str.Length; i++)
  int temp=int.Parse(str[i].ToString());
  value += temp * temp;
 return value;

About Bahrudin Hrnjica

PhD in Mechanical Engineering, Microsoft MVP for Visual Studio and Development Technologies. Likes .NET, Math,Data Science, Evolutionary Algorithms, Machine Learning, Blogging.

Posted on 01/03/2010, in C#, Project Euler and tagged . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s