Advertisement
Spocoman

03. Factorial Division

Oct 26th, 2023
630
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.30 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. double factorial(int n) {
  6.     if (n == 0) {
  7.         return 1;
  8.     }
  9.     else {
  10.         return (n * factorial(n - 1));
  11.     }
  12. }
  13.  
  14. int main() {
  15.     int n1, n2;
  16.     cin >> n1 >> n2;
  17.  
  18.     printf("%.2f\n", factorial(n1) / factorial(n2));
  19.  
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement