Skip to content

Instantly share code, notes, and snippets.

@chechedotmx
Created April 19, 2014 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chechedotmx/1fef4c8e941f9edae76d to your computer and use it in GitHub Desktop.
Save chechedotmx/1fef4c8e941f9edae76d to your computer and use it in GitHub Desktop.
Palindromos de producto de 2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AldeaDigital
{
class Program
{
static void Main(string[] args)
{
int rangoMenor = 100;
int rangoMayor = 999;
List<int> listaPalindromos = new List<int>();
for (int i = rangoMenor; i <= rangoMayor; i++)
{
for (int j = rangoMenor; j < rangoMayor; j++)
{
int multiplicacion = i * j;
String multiplicacionString = multiplicacion.ToString();
if (multiplicacionString.SequenceEqual(multiplicacionString.Reverse()))
{
listaPalindromos.Add(multiplicacion);
}
}
}
Console.WriteLine(listaPalindromos.ToArray().Max() + " es el palindromo más grande derivado del producto de 2 números en el rango " + rangoMenor + " a " + rangoMayor);
Console.ReadLine();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment