This code basically computes nCr to print a pascal's triangle.
#include <stdio.h>
int nCr(int n,int r){
if (r == 0 || r == n || n == 1 || n == 0){
return 1;
}
else{
return nCr(n-1,r) + nCr(n-1,r-1);
}
}
How would this function be turned into an iterative version?
I forgot to mention this before, but the solution has to be without using lists, to somehow, convert this exact recursive logic to an iterative one.