到目前为止,这是我的代码。
public int getsum (int n){
int num = 23456;
int total = 0;
while (num != 0) {
total += num % 10;
num /= 10;
}
}
问题是我不能/不知道如何将其更改为递归方法我是递归的新方法,我需要一些帮助来实现此方法以更改它以使其递归。
原文由 user1268088 发布,翻译遵循 CC BY-SA 4.0 许可协议
简短,递归并完成工作: