I am trying to solve marbles problem (http://www.codechef.com/problems/MARBLES) and getting SIGFPE error. It is written that this error comes due to division by 0 but i am unable to figure out why it is happening in my code.

```
#include<stdio.h>
unsigned long comb(unsigned long n, unsigned long r)
{
if(n==r || r==0)
return (unsigned long)1;
if(r==1)
return n;
unsigned long nn=1,nr=1;
while(r)
{
nn=nn*(n--);
nr=nr*(r--);
}
return (nn/nr);
}
int main()
{
int t;
unsigned long n,r;
scanf("%d",&t);
while(t--){
scanf("%lu%lu",&n,&r);
printf("%lu\n",comb(--n,--r));
}
return 0;
}
```