Пример #1
0
        static void Fibonachy()
        {
            Console.WriteLine("\n\tFibonachy\n\n");
            int num = ConsoleRead.Int("Imput count elements: ");

            int[] fibonachi = new int[num];
            for (int i = 0; i < num; i++)
            {
                int k = i - 2;
                if (k < 0)
                {
                    fibonachi[i] = i;
                }
                else
                {
                    fibonachi[i] = fibonachi[i - 1] + fibonachi[k];
                }
            }
            Console.WriteLine($"\nFibonachi array:\n");
            for (int i = 0; i < num; i++)
            {
                Console.Write(fibonachi[i] + " ");
            }
            StartMenu.EnterClearConsole();
        }
Пример #2
0
        static void Progressions()
        {
            Console.WriteLine("\n\tArithmetic and Geometric progression\n\n");

            int startNum  = ConsoleRead.Int("Input start num: ");
            int increment = ConsoleRead.Int("Input increment: ");
            int countNum  = ConsoleRead.Int("Input number of elements: ");

            int[] arrA = new int[countNum];
            int[] arrG = new int[countNum];

            arrA[0] = startNum;
            arrG[0] = startNum;

            for (int i = 1; i < countNum; i++)
            {
                arrA[i] = arrA[i - 1] + increment;
                arrG[i] = arrG[i - 1] * increment;
            }

            Kiselev_Andrey.Array.Print(arrA, "Arithmetic progression:");
            Kiselev_Andrey.Array.Print(arrG, "Geometric progression:");

            StartMenu.EnterClearConsole();
        }
Пример #3
0
        static void Obratny()
        {
            Console.WriteLine("\n\tInverted num\n\n");
            int num = ConsoleRead.Int("Imput number: ");
            int res = 0, temp = num;

            while (temp != 0)
            {
                res  *= 10;
                res  += temp % 10;
                temp /= 10;
            }
            Console.WriteLine($"Inverted number: {res}");
            StartMenu.EnterClearConsole();
        }