using System.Collections.Generic;
public class HomeController : Controller
public ActionResult Index()
return View(new MathViewModel());
public JsonResult GenerateArray(int arraySize)
int[] array = new int[arraySize];
Random random = new Random();
List<string> outputList = new List<string>();
for (int i = 0; i < array.Length; i++)
array[i] = random.Next(1, 1000);
for (int i = 0; i < array.Length - 1; i++)
for (int j = 0; j < array.Length - i - 1; j++)
if (array[j] > array[j + 1])
outputList.Add(string.Join(", ", array));
return Json(new { array = array, outputList = outputList }, JsonRequestBehavior.AllowGet);