Explore what CodeHS has to offer for districts, schools, and teachers.
Click on one of our programs below to get started coding in the sandbox!
View All
Given the following method:
public static int mystery(int n) { if (n <= 0) { return n; } return n % 10 + mystery(n / 10); }
Including the initial call, how many times will the function be called for mystery(1234)?
mystery(1234)
2
3
4
5
10