fork(5) download
  1. #include<stdio.h>
  2. main()
  3. {
  4. int n,r;
  5. float ncr;
  6. printf("Enter values of n and r\n");
  7. scanf("%d%d",&n,&r);
  8. ncr=recbicoff(n,r);
  9. printf("Binomial coefficient of c(%d,%d) is %f",n,r,ncr);
  10.  
  11. }
  12. int recbicoff(int n,int r)
  13. {
  14. if(r>n)
  15. {
  16. printf("The value of n can't be less than r");
  17.  
  18. }
  19. if(r==0||r==n)
  20. {
  21. return(1);
  22. }
  23. else
  24. {
  25. return(recbicoff(n-1,r-1)+recbicoff(n-1,r));
  26. }
  27. }
Success #stdin #stdout 0s 2164KB
stdin
15 10
stdout
Enter values of n and r
Binomial coefficient of c(15,10) is 3003.000000