extern short const_array[2000] long fun(short x) { static array[2000]; long res = 0; for (int i=1999; i>0; i–-) array[i] = array[i-1]; array[0] = x; for (i=0; i<2000, i++) res += array[i]*const_array[i]; return res; }

Hi guys,

writing to array is taking 5cycles, assigning and writing to variable takes 5cycles, other operation takes one cycle, assume that time of for loop itself is zero (ideal case), so the time complexity of this function that I calculated it is about 23n+6 (n is equal in my case to 2000), how do I reduce its time complexity more less? I tried to reduce its time complexity more and more and arrived to 18n, but I "reckon" we can arrive to about a half/quarter time complexity of 23n+6, any help/suggestion please?

thanks a lot !