Esempio n. 1
0
 static void Main(string[] args)
 {
     string matrixNumbers = FileReader.ReadFile("Nums.txt", System.Text.Encoding.UTF8);
     string[] nums = matrixNumbers.Replace("\r\n", "|").Split('|');
     LargeNumberModel result = new LargeNumberModel("0");
     foreach (string num in nums)
     {
         LargeNumberModel ln = new LargeNumberModel(num);
         result = result + ln;
     }
     Console.WriteLine(result.ToString().Substring(0,10));
     Debug.WriteLine(result.ToString().Substring(0, 10));
     Console.Read();
 }
Esempio n. 2
0
 static LargeNumberModel Pow(LargeNumberModel num, int pow)
 {
     if (pow < 0)
         throw new ApplicationException("Pow can not be smaller than 0");
     if (pow == 0)
         return new LargeNumberModel("1");
     if (pow == 1)
         return num;
     LargeNumberModel result = new LargeNumberModel(num.ToString());
     int basenum = int.Parse(num.ToString());
     for (int i = 1; i < pow; i++)
     {
         result = result * basenum;
     }
     return result;
 }
Esempio n. 3
0
 static bool CheckPalindromic(LargeNumberModel number)
 {
     string reverse = ReverseNumber(number).ToString();
     if (string.Equals(number.ToString(),reverse))
         return true;
     return false;
 }
Esempio n. 4
0
 static bool CanGetPalindromicIn50Cycles(LargeNumberModel number)
 {
     LargeNumberModel temp = new LargeNumberModel(number.ToString());
     for (int i = 0; i < 50; i++)
     {
         LargeNumberModel reverse = ReverseNumber(temp);
         LargeNumberModel sum = temp + reverse;
         if (CheckPalindromic(sum))
             return true;
         temp = sum;
     }
     return false;
 }
Esempio n. 5
0
 static void Main(string[] args)
 {
     LargeNumberModel num = new LargeNumberModel("2"); // 11930336
     for (int i = 1; i < 1000; i++ )
         num = num * 2;
     Console.WriteLine(num);
     string result = num.ToString();
     int sum = 0;
     for (int i = 0; i < result.Length; i++)
     {
         sum += int.Parse(result.Substring(i, 1));
     }
     Console.WriteLine(string.Format("sum:{0}",sum));
     Console.Read();
 }
Esempio n. 6
0
 static string SignNum(LargeNumberModel num)
 {
     string numStr = num.ToString();
     return new string(numStr.OrderBy(x => x).ToArray());
 }