fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int pascal(int n,int k)
  5. {
  6. if(k==0)
  7. return 1;
  8.  
  9. if(k==n)
  10. return 1;
  11.  
  12. return pascal(n-1,k-1) + pascal(n-1,k);
  13. }
  14.  
  15. int main() {
  16. int n,k;
  17. cout<<"Enter the values of n and k";
  18. cin>>n>>k;
  19. cout<<endl<<pascal(n,k);
  20. return 0;
  21. }
Success #stdin #stdout 0s 3416KB
stdin
5 2
stdout
Enter the values of n and k
10