Euler Problem 206


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;

namespace EulerProblem206
{
    class Program
    {
        static void Main(string[] args)
        {
            for (long i = 1000000000; i < 10000000000; i+=10)
            {
                string numb = BigInteger.Pow(i, 2).ToString();
                if (numb.Length < 19)
                    continue;
                else if (numb.Length > 19)
                    break;
                if (numb.Length == 19)
                {
                    if (numb[0] == '1' && numb[2] == '2' && numb[4] == '3' && numb[6] == '4' && numb[8] == '5' &&
                    numb[10] == '6' && numb[12] == '7' && numb[14] == '8' && numb[16] == '9' && numb[18] == '0')
                    {
                        Console.WriteLine(i);
                        break;
                    }
                }

            }
            Console.WriteLine("Press any key to continue...");
            Console.Read();
        }
    }
}

About Bahrudin Hrnjica

PhD in Mechanical Engineering, Microsoft MVP for .NET. Likes .NET, Math, Mechanical Engineering, Evolutionary Algorithms, Blogging.

Posted on 07/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:

WordPress.com Logo

You are commenting using your WordPress.com 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