Advertisement
chevengur

Вводный курс: основы C++ | Урок 4: Зачем нужны функции 1/2

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