Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/Manvityagi/PW-Skills-Java-Course-Codes
/ sod
Method
sod
Lecture 29 - Recursion PS2/src/SOD.java:2–5 ·
view source on GitHub ↗
(int n)
Source
from the content-addressed store, hash-verified
1
public
class
SOD {
2
static
int
sod(
int
n){
3
if
(n >= 0 && n <= 9)
return
n;
4
return
sod(n/10) + n%10;
5
}
6
7
public
static
void
main(String[] args) {
8
System.out.println(sod(12345));
Callers
1
main
Method · 0.95
Calls
no outgoing calls
Tested by
no test coverage detected