Esempio n. 1
0
        static void Main(string[] args)
        {
            DifferentTasks.RunMutuallySimpleNumber();
            DifferentTasks.RunPerfectNumbersOnALine();
            DifferentTasks.RunTranslationOfNumberSystems();
            DifferentTasks.RunFactorialNumbersAsTheProductOfThreeConsecutivePrimes();
            StringTasks.RunSortText();
            ArraysTasks.RunSummaTwoSmallestAndTwoLargestElementArray();
            ArraysTasks.RunMaximumDoesNotDecreaseSequence();

            // Console.WriteLine("A=" + (int)'А' +"; a=" + (int)'а'+ "; Я=" + (int)'Я' + "; я=" + (int)'я' + ";");
            //  WorkWithTheConsole.
        }
Esempio n. 2
0
        // алгоритм поиска совершенных чисел
        internal static string PerfectNumberToFind(int startLine, int finishLine)
        {
            perfectNumber = "";
            int  number;
            int  summa;
            bool flag = false;

            StringTasks.SwapIntAndInt(ref startLine, ref finishLine);
            for (number = startLine; number < finishLine; number++)
            {
                summa = 0;
                if (number % 2 == 0)
                {
                    for (int index = 1; index <= number / 2; index++)
                    {
                        if (number % index == 0)
                        {
                            summa = summa + index;
                            if (index == number / 2 && number == summa)
                            {
                                perfectNumber += " " + number;
                                flag           = true;
                            }
                        }
                    }
                }
                else
                {
                    continue;
                }
            }
            OutputPerfectNumbers(perfectNumber, flag);
            if (flag)
            {
                return("Perfect number: " + perfectNumber);
            }
            else
            {
                return("No perfect numbers");
            }
        }