using System; // Thanks to: // http://b...content-available-to-author-only...x.net/2013/08/deterministic-miller-rabin-primality.html // https://g...content-available-to-author-only...b.com/softwx/SoftWx.Numerics namespace ConsoleApp1 { // Найдите все натуральные n ∈ (0..1000), такие что 2ⁿ - n кратно 7. // Find all natural numbers n ∈ (0..1000) such that 2ⁿ - n is a multiple of 7. class Program { // эта функция возвращает value ^ exponent % modulus static uint ModPow(uint value, uint exponent, ushort modulus) { uint result = 1; if ((exponent & 1) != 0) result = value; while ((exponent /= 2) != 0) { value = value * value % modulus; if ((exponent & 1) != 0) result = result * value % modulus; } return result; } static void Main() { for (uint i = 1; i < 1000; ++i) if (ModPow(2, i, 7) == i % 7) Console.Write(i + "\t"); // Console.ReadKey(true); } } }