import java.util.*;
public class main{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
while(sc.hasNextLine())
{
String str = sc.nextLine();
if(str.equals("0"))
break;
while(str.length() > 1)
{
int num = 0;
for(int i = 0; i < str.length(); i++)
num += str.charAt(i) - '0';
str = Integer.toString(num);
}
System.out.println(str);
}
}
};
import java.util.*;
public class main{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
while(sc.hasNextLine())
{
int num = Integer.parseInt(sc.nextLine());
if(num == 0)
break;
while(num >= 10)
{
int temp = 0;
while(num != 0)
{
temp += num % 10;
num /= 10;
}
num = temp;
}
System.out.println(num);
}
}
};
留言
張貼留言