Advertisement
Trawka011

Untitled

Oct 13th, 2022
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.22 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int f(int n) {
  4.  
  5.     if (n == 0)
  6.     {
  7.         return 0;
  8.     }
  9.     else return  f(n / 10) +n %10;
  10. }
  11. int main() {
  12.     int n;
  13.     cin >> n;
  14.     cout << f(n);
  15.     return 0;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement