Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class App {
- public static void main(String[] args) {
- var result = sumofDigits(123);
- System.out.println(result);
- }
- public static int sumofDigits(int n) {
- if(n<1){
- return 0;
- }
- return n % 10 + sumofDigits(n / 10);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement