public PrimalCheckerViewModel Check(PrimalCheckerViewModel model) { model.PrimalList = new List <int>(); var stopwatch = System.Diagnostics.Stopwatch.StartNew(); for (int i = 0; i <= model.Value1; i++) { int count = 0; for (int j = 1; j <= i; j++) { if (i % j == 0) { count++; } } if (count == 2 || i == 1) { model.PrimalList.Add(i); } } model.Amount = model.PrimalList.Count(); stopwatch.Stop(); model.Time = stopwatch.ElapsedMilliseconds.ToString() + "ms"; return(model); }
public IActionResult DoNumbers(PrimalCheckerViewModel model, string command) { if (command == "DoNumber") { return(Redirect("Index")); } else { return(View()); } }
public IActionResult Index(PrimalCheckerViewModel model) { var modeldata = _modelService.Check(model); return(View(modeldata)); }