1
\$\begingroup\$

So I made a code to improve my programming skills and it works just fine, but it looks chaotic for me. Is there is a better and more efficient way to do it? If you have any ideas/tips I would love to hear them.

using System;

 namespace Palindrome
  {
   internal class Program
   {
    private static int Palindroming(int a)
    {
        var results = 0;


        while (a > 0)
        {
            results = results * 10 + a % 10;
            a /= 10;
        }


        return results;
    }

    private static void Main(string[] args)
    {
        var multiply = 0;
        var largestMultiply = 0;
        var largest = 0;
        for (var i = 100; i <= 999; i++)
        for (var j = 100; j <= 999; j++)
        {
            var temp = multiply;
            multiply = i * j;

            if (multiply == Palindroming(multiply))
                if (temp > largestMultiply)
                {
                    largestMultiply = temp;

                    if (multiply > largestMultiply)
                        largest = multiply;
                }
        }

        Console.WriteLine(largest);
        Console.ReadLine();
    }
  }
}
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.