Example #1
0
        /// <summary>
        /// Main Thread
        /// </summary>
        static void Main()
        {
            const int MAX_NUMBER = 100;

            for (int i = 2; i <= MAX_NUMBER; i++)
            {
                numbers.Add(i, PrimeNumber.GetIntegerFactorization(i));
            }

            for (int i = 2; i <= MAX_NUMBER; i++)
            {
                foreach (KeyValuePair <int, Dictionary <Int64, Int64> > kvp in numbers)
                {
                    StringBuilder powDescribed = new StringBuilder();

                    foreach (KeyValuePair <Int64, Int64> p in kvp.Value)
                    {
                        powDescribed.Append(
                            p.Key.ToString("D4")).Append("@").Append((p.Value * i).ToString("D4"));
                    }
                    if (!pows.Contains(powDescribed.ToString()))
                    {
                        pows.Add(powDescribed.ToString());
                    }
                }
            }

            Console.WriteLine("Solution: {0}", pows.Count);
        }
Example #2
0
        /// <summary>
        /// Main Thread
        /// </summary>
        static void Main()
        {
            const int maxNumber = 20;

            Dictionary <Int64, Int64> factors = new Dictionary <Int64, Int64>();

            for (int i = 2; i < maxNumber; i++)
            {
                foreach (KeyValuePair <Int64, Int64> kvp in PrimeNumber.GetIntegerFactorization(i))
                {
                    if (factors.ContainsKey(kvp.Key))
                    {
                        if (kvp.Value > factors[kvp.Key])
                        {
                            factors[kvp.Key] = kvp.Value;
                        }
                    }
                    else
                    {
                        factors.Add(kvp.Key, kvp.Value);
                    }
                }
            }

            Int64 result = (from p in factors
                            select Int64.Parse(Math.Pow(p.Key, p.Value).ToString())).Aggregate((total, next) => total * next);

            Console.WriteLine("Solution: {0}", result);
        }
Example #3
0
        /// <summary>
        /// Main Thread
        /// </summary>
        static void Main()
        {
            bool itemNotFound = true;

            for (int i = 1; itemNotFound; i++)
            {
                Dictionary <Int64, Int64> d1 = PrimeNumber.GetIntegerFactorization(i);
                Dictionary <Int64, Int64> d2 = PrimeNumber.GetIntegerFactorization(i + 1);
                Dictionary <Int64, Int64> d3 = PrimeNumber.GetIntegerFactorization(i + 2);
                Dictionary <Int64, Int64> d4 = PrimeNumber.GetIntegerFactorization(i + 3);

                bool distinctPrimes = CompareFactorizations(d1, d2) && CompareFactorizations(d1, d3) && CompareFactorizations(d1, d4) &&
                                      CompareFactorizations(d2, d3) && CompareFactorizations(d2, d4) &&
                                      CompareFactorizations(d3, d4);

                if (distinctPrimes)
                {
                    itemNotFound = false;
                    Console.WriteLine("Solution: {0}", i);
                }
            }
        }
Example #4
0
 /// <summary>
 /// Main Thread
 /// </summary>
 static void Main()
 {
     Console.WriteLine("Solution: {0}", PrimeNumber.GetIntegerFactorization(600851475143).Last().Key);
 }