コード例 #1
0
        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);
        }
コード例 #2
0
 public IActionResult DoNumbers(PrimalCheckerViewModel model, string command)
 {
     if (command == "DoNumber")
     {
         return(Redirect("Index"));
     }
     else
     {
         return(View());
     }
 }
コード例 #3
0
        public IActionResult Index(PrimalCheckerViewModel model)
        {
            var modeldata = _modelService.Check(model);

            return(View(modeldata));
        }