/*********************************** * Section : 15 * Machine No. : N * Roll No. : 19CS100XY * Name : Aritra Hazra * Assignment No : 5B * Description : Counting Partitions ***********************************/ #include unsigned long countP ( unsigned long n , unsigned long m ) { unsigned long i, s; if (n == 0) return 1; s = 0; for (i=m; i<=n; ++i) s += countP(n-i,i); return s; } unsigned long countPNoRep ( unsigned long n , unsigned long m ) { unsigned long i, s; if (n == 0) return 1; s = 0; for (i=m; i<=n; ++i) s += countPNoRep(n-i,i+1); return s; } int main () { unsigned long n; printf("Enter Number of Gryphons (n): "); scanf("%lu", &n); //printf("n = %lu\n", n); printf("Count of All Partitions = %lu\n", countP(n,1)); printf("Count of Partitions without Repetitions = %lu\n", countPNoRep(n,1)); printf("\n"); }