1109: 数根(函数专题)
import java.util.Scanner;
public class Main {
public static int digitSum(int n){
int res=0;while(n>0){
res+=n%10;n=n/10;}return res;}public static void main(String[] args) {
Scanner cin = new Scanner(System.in);int n=cin.nextInt();while(n>=10)n=digitSum(n);System.out.println(n);}
}