#include int countGroupLine ( int n , int last ) { int i, cnt; cnt = 1; for (i=last+2; i<=n; ++i) cnt += countGroupLine(n,i); return cnt; } int countGroupCircle ( int n , int last , int firstChosen ) { int i, cnt, bound; bound = (firstChosen) ? n-1 : n; cnt = 1; for (i=last+2; i<=bound; ++i) cnt += countGroupCircle(n,i,firstChosen); return cnt; } int main () { int n, cnt; printf("Enter number of persons : "); scanf("%d", &n); if (n <= 0) { printf("Enter a positive integer next time...\n"); exit(0); } cnt = countGroupLine(n,-1); printf("Number of nonbelligerent collections in a line = %d\n", cnt); cnt = countGroupCircle(n,0,0) + countGroupCircle(n,1,1); printf("Number of nonbelligerent collections in a circle = %d\n", cnt); exit(0); }