Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace Кенгуру
- {
- class Program
- {
- static void Main(string[] args)
- {
- Problem27();
- Console.WriteLine(A(2019));
- Console.ReadLine();
- }
- static void Problem27()
- {
- int N = 2019;
- List<int> list = new List<int>() { 49};
- for (int i = 1; i < N; i++)
- {
- int sumPreviousNum = 0; //сумма цифр попередньго числа
- for (int j = 0; j < list[i - 1].ToString().Length; j++)
- sumPreviousNum += int.Parse(list[i - 1].ToString()[j].ToString()); //49 = "49" = '4' = "4" = 4
- list.Add((int) Math.Pow(sumPreviousNum + 1, 2));
- }
- Console.WriteLine(list[list.Count - 1]);
- }
- //питання 27
- static int A(int N)
- {
- if (N <= 1) return 49;
- return (int) Math.Pow(Amount(A(N - 1)) + 1, 2); //для знаходження даного числа потрібно (сума цифр попередньго + 1)^2
- }
- //вертає сумму цифр числа
- static int Amount(int x)
- {
- int sumNum = 0; //сумма цифр числа
- for (int j = 0; j < x.ToString().Length; j++)
- sumNum += int.Parse(x.ToString()[j].ToString()); //49 = "49" = '4' = "4" = 4
- return sumNum;
- }
- static string Problem21()
- {
- List<int> list = new List<int>();
- int N = 1024;
- for (int i = 1; i <= N; i++)
- {
- if (N % i == 0)
- list.Add(i);
- }
- ulong b = 1;
- int a = 0;
- foreach (var item in list)
- {
- b *= (ulong)item;
- a += item;
- }
- Console.WriteLine(a);
- Console.WriteLine(b);
- if (Math.Pow((a - 1), 5) == b) return "A";
- if (Math.Pow((a + 1), 5) == b) return "Б";
- if (Math.Pow(a, 5) == b) return "В";
- if (Math.Pow(a, 5) - 1 == b) return "Г";
- if (Math.Pow(a, 5) + 1 == b) return "Д";
- return "Шось не то";
- }
- static int CountDiagonal(int count) => (count * count - (3 * count)) / 2;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement