private static void WriteInfo(NaturalNumberItem item) { //var judge = item.Judge(); // if(item.IsPrime != judge|| item.IsPrime) //Console.WriteLine($"{item.Number}\t{item.IsPrime}\t{item.Binary}\t{judge}"); Console.WriteLine($"{item.Number}\t{item.IsPrime}\t{item.Binary}\t{item.NonPrimeOdd()}"); }
private static void InitPrime() { for (int i = 0; i < Size; i++) { AllNumberArray[i] = new NaturalNumberItem { IsPrime = false, Binary = BinaryUtil.GetBinaryString(i), Number = i }; } for (int i = 0; i < Size; i++) { var item = AllNumberArray[i]; if (!item.IsMark && i > 1) { item.IsPrime = true; PrimeDict.Add(i, item); PrimeList.Add(i); int n = 2; int l; while ((l = n * i) < Size) { if (!AllNumberArray[l].IsMark) { AllNumberArray[l].IsMark = true; } n++; } } } }