Fekke

Untitled

Mar 23rd, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.58 KB | None | 0 0
  1. public static BigInteger Palindrome(bool isEven, BigInteger[] i)
  2.         {
  3.             BigInteger x, y, a = 0;
  4.             string s = a.ToString();
  5.             if (isEven)
  6.             {
  7.                 for (x = i[0]; x > 0; x--)
  8.                 {
  9.                     x--;
  10.                     if ((x * i[1]) < a) return a;
  11.                     for (y = i[1]; y > 0; y--)
  12.                     {
  13.                         if (x * y < a) y = 0;
  14.                         s = (x * y).ToString();
  15.                         if (s.SequenceEqual(s.Reverse()) && BigInteger.Parse(s) > a)
  16.                         {
  17.                             //Console.WriteLine("Even: {0} * {1} = {2}", x, y, s);
  18.                             a = BigInteger.Parse(s);
  19.                             y = 0;
  20.                         }
  21.                     }
  22.                 }
  23.             }
  24.             else
  25.             {
  26.                 for (x = i[0]; x > 0; x--)
  27.                 {
  28.                     if ((x * i[1]) < a) return a;
  29.                     for (y = i[1]; y > 0; y--)
  30.                     {
  31.                         if (x * y < a) y = 0;
  32.                         s = (x * y).ToString();
  33.                         if (s.SequenceEqual(s.Reverse()) && BigInteger.Parse(s) > a)
  34.                         {
  35.                             //Console.WriteLine("Uneven: {0} * {1} = {2}", x, y, s);
  36.                             a = BigInteger.Parse(s);
  37.                             y = 0;
  38.                         }
  39.                     }
  40.                     x--;
  41.                 }
  42.             }
  43.             return a;
  44.         }
Advertisement
Add Comment
Please, Sign In to add comment