using System; using System.Collections.Generic; using System.Linq; public class Test { public static void Main() { while (true) { Console.WriteLine("Zadej:"); int vstup = int.Parse(Console.ReadLine()); var data = new List>(); var cislo = 1; var opakIndex = 0; while (true) { var vysledek = cislo/vstup; var zbytek = cislo%vstup; if (data.Any(o => o.Item1 == cislo)) { opakIndex = data.FindIndex(o => o.Item1 == cislo); break; } data.Add(new Tuple(cislo, vysledek)); if (zbytek == 0) { opakIndex = data.Count; break; } cislo = zbytek*10; } Console.WriteLine("pred: 0." + data.Skip(1).Take(opakIndex - 1).Select(o => o.Item2).Aggregate("", (cur, nex) => cur + nex)); Console.WriteLine("per:" + data.Skip(opakIndex).Select(o => o.Item2).Aggregate("", (cur, nex) => cur + nex)); } } }