Hello,
I am trying to write a program that determines how many calculations it would take to find the determinant of a matrix, and how long it would take to do those calculations. I keep getting 0 seconds for an output. Can anybody see where I may have gone wrong?
Code:
double mults_for_det(int n)
{
if(n == 1)
return 0;
else
return n + n * mults_for_det(n - 1);
}
int main(void)
{
int n;
double mults;
clock_t start, end;
printf("Enter a number for an nxn matrix.\n");
scanf("%d",&n);
start = clock();
mults = mults_for_det(n);
end = clock();
printf("For n = %d, the %g multiplications take %g seconds.\n",n,
mults,(double)(end - start) / (double)CLOCKS_PER_SEC);
return 0;
}