## Adobe Interview Question

MTSs**Country:**India

**Interview Type:**In-Person

You generate (R choose k) in terms of (R choose k-1).

Possible code:

```
// Row R: (R choose 0), (R choose 1), ..(R Choose R).
List <ulong > PascalRow(uint R) {
uint j = 1;
ulong coeff = 1;
List <ulong> coeffs = new List<ulong>();
coeffs.Add(coeff);
while (j <= R) {
coeff = (coeff*(R-j+1))/j;
coeffs.Add(coeff);
}
return coeffs;
}
```

```
void pascalTriangle(int n)
{
int **a=NULL;
a = (int **)malloc(sizeof(int *) * n);
for(int i=0;i<n;i++)
{
int * row=(int *)malloc(sizeof(int) * (i+1));
row[0]=1;
for(int j=1;j<i;j++)
{
row[j]= a[i-1][j-1]+a[i-1][j];
}
row[i]=1;
a[i]=row;
}
for(int i=0;i<n;i++)
{
for(int j=0;j<=i;j++)
{
cout<<a[i][j]<<" ";
}
cout<<endl;
}
for(int i=0;i<n;i++)
free (a[i]);
free(a);
}
```

//1

- madmonkey October 06, 2012//11

//121

//1331

//14641

//15101051

#include <stdio.h>

#define MAX 10

int main()

{

for(int y = 0; y < MAX; y++)

{

int c = 1;

for(int x = 0; x <= y; x++)

{

printf("%d",c);

c = c * (y - x) / (x + 1);

}

printf("\n");

}

printf("\n");

return 0;

}