Advertisement
chevengur

Полный перебор и оптимизация перебора | Перестановки

Sep 13th, 2023 (edited)
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.20 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int factorial(int x) {
  4.     if (x == 0 || x == 1) {
  5.         return 1;
  6.     }
  7.    
  8.     return x * factorial(x - 1);
  9.        
  10. }
  11.  
  12. int main() {
  13.     int x;
  14.     std::cin >> x;
  15.     std::cout << factorial(x);
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement