public static void Main()
var alf = "абвгдеёжзийклмнопрстуфхцчшщъыьэюя";
var str = "скоро новый год";
str = str.Replace(" ", "");
for(var i = 0; i < str.Length; i++){
res += alf[getNumberLessMod(alf.IndexOf(str[i]) + a*i + b, m)];
for(var i = 0; i < res.Length; i++){
var c = getNumberLessMod(alf.IndexOf(res[i]) - a*i-b,m );
public static String methodEiler(int a, int b, int m) {
String formula = String.Format("{0}x = {1}(mod {2})", a, b, m);
Console.WriteLine(formula);
String mod = String.Format("(mod {0})", m);
int countSolution = algorithmEvklid(a, m);
if (countSolution != 0 && b % countSolution == 0) {
a = getNumberLessMod(a, m);
b = getNumberLessMod(b, m);
if (countSolution != 1) {
formula = String.Format("{0}x = {1}(mod {2})", a, b, m);
Console.WriteLine(formula);
int fx = functionEiler(m);
a = (int) Math.Pow(a, 2);
a = getNumberLessMod(a, m);
b = getNumberLessMod(b, m);
int c = getNumberLessMod((a * b), m);
for (int i = 0; i < countSolution; i++) {
Console.WriteLine(string.Format("x={0}{1}", (m * i + c), mod));
Console.WriteLine("решений нет");
public static int getNumberLessMod(int number, int mod) {
while (Math.Abs(number) > mod) {
public static int algorithmEvklid(int a, int b) {
while (b != 0 && a != 0) {
public static int functionEiler(int x) {
int countPrimeNumber = 0;
for (int i = 1; i < x; i++) {
if (algorithmEvklid(i, x) == 1) {