public static int Simple_search_optimized(int n) { int count = 0; NArray <int> arr = new NArray <int>(); arr.SingleArray(); for (int i = 2; i <= n; i++) { if (prime_optimized(i, arr)) { arr.Add(i); count++; } } return(count); }