I am trying to generate runtimes for this fibbonacci series program for iterative algorithm and after generating the fibbonacci number for almost 25k values, the runtime taken is staying constant for some reason. Is this because of the subprocess call I am using in python script or something else?
Python Script to run the program and record time:
start = time.time()
subprocess.run(command, timeout=TIMEOUT)
end = time.time()
result = end - start
C Program:
unsigned long long first = 0, second = 1, result;
if (n <= 1) return n;
for (int i = 0; i < n; i++)
{
if (i <= 1)
result = i;
else
{
result = first + second;
first = second;
second = result;
}
}
return result;
I tried to change the number of values to a lot more and it still stays constant. This algorithm should be O(n). Right now I am getting values around 0.00200 seconds, It doesnt go above 0.003 and below 0.001.