#include <stdio.h>
int fib_iter(int n)
{
if(n == 0) return 0;
if(n == 1) return 1;
int pp = 0;
int p = 1;
int result = 0;
for(int i = 2; i <= n; i++)
{
result = p + pp;
pp = p;
p = result;
}
return result;
}
int main(void)
{
int m;
printf(" Get Fibonacci\n");
printf("Enter an integer for m = ");
scanf_s("%d", &m);
if (m < 0) return 1;
for(int i = 0; i <= m; i++)
{
printf("fib(%d) = %d\n", i, fib_iter(i));
}
return result;
}
Program above was coded to print out Fibonacci numbers like fib(0), fib(1), ...fib(m). What is the Time Complexity of this program according to integer m described with Big-O notation? Explain why. (Let's say the time calculation for printf() functions are ignored. The console output for integer m does not allow any number bigger than INT_MAX. Therefore, ignore the overflow.)
Should the answer be O(m) or O(m^2)?