Pastebin
API
tools
faq
paste
Login
Sign up
SHARE
TWEET
Sum of Digits using Recursion in C++
jasonpogi1669
Oct 8th, 2021
(
edited
)
96
0
Never
Add comment
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!
C++
0.20 KB
| None
|
0
0
raw
download
clone
embed
print
report
#include <bits/stdc++.h>
using
namespace
std
;
int
Sum
(
int
n
)
{
return
(
n
%
10
+
(
n
>=
10
?
Sum
(
n
/
10
)
:
0
)
)
;
}
int
main
(
)
{
int
n
;
cin
>>
n
;
cout
<<
Sum
(
n
)
<<
'
\n
'
;
return
0
;
}
Add Comment
Please,
Sign In
to add comment
Public Pastes
Untitled
Python | 28 min ago | 11.80 KB
konecne vse pro 4 figury a 993 very good
Python | 50 min ago | 3.38 KB
🤑 G2A.com Free Gift Card Guide May 2024 FIX 🤑
GetText | 1 hour ago | 0.39 KB
Swimbot Error
Python | 2 hours ago | 0.67 KB
Ps99 Script
Lua | 2 hours ago | 0.08 KB
Decimal to Roman
PHP | 2 hours ago | 4.19 KB
Brave new world
C# | 2 hours ago | 6.10 KB
Slot Disk Writer
Lua | 2 hours ago | 1.43 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!