Project Euler #4 in C#
I'm attempting to do Project Euler problem #4 in C#. The problem I'm
having is that when the code runs a console window briefly appears and
then goes away. I don't know what the problem could be as I'm relatively
new to programming.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
for (int i = 1000; i > 100; i--)
for (int j = 1000; j > 100; j--)
PalCheck(i * j);
}
static void PalCheck(int original)
{
var reversed = new
string(Convert.ToString(original).ToCharArray().Reverse().ToArray());
if (Convert.ToString(original) == reversed)
Console.WriteLine(original);
Console.ReadKey();
}
}
}
No comments:
Post a Comment