public int calc() { ggt ggt = new ggt(a, b); return(a * b / ggt.calc()); }
static void Main(string[] args) { char choice = ' '; string[] tokens; int a, b; char choicerec = ' '; ggt g; kgv k; eras e; while (choice != 'x') { Console.WriteLine("\nHai. Whatcha wanna do?\npress 'k' for kgv, 'g' for ggt, 'e' for erastothenes, 'x' to exit"); choice = Console.ReadKey().KeyChar; switch (choice) { case 'k': Console.WriteLine("\nplz enter two numbers to compute"); tokens = Console.ReadLine().Split(); a = int.Parse(tokens[0]); b = int.Parse(tokens[1]); k = new kgv(a, b); Console.WriteLine("\nthe smallest common multiple is " + k.calc().ToString()); break; case 'g': Console.WriteLine("\nplz enter two numbers to compute"); tokens = Console.ReadLine().Split(); a = int.Parse(tokens[0]); b = int.Parse(tokens[1]); Console.WriteLine("\nwanna do recursive stuff? y/n"); choicerec = Console.ReadKey().KeyChar; if (choicerec == 'y') { g = new ggt(a, b, true); } else { g = new ggt(a, b); } Console.WriteLine("\nthe largest common divisor is " + g.calc().ToString()); break; case 'e': Console.WriteLine("\nWhats the limit?"); tokens = Console.ReadLine().Split(); a = int.Parse(tokens[0]); e = new eras(a); Console.WriteLine("\nThe Prime numbers are: "); int i = 0; foreach (int item in e.Calc()) { if (i != 0 && i % 10 == 0) { Console.Write('\n'); } Console.Write(item.ToString() + " "); i++; } break; default: Console.WriteLine("huh, what? try again"); break; } } }