Sum Of Digits

0

0 votes
Problem

Given a number N .Add the digits in it until it becomes single digit.

For Example: 

N=972

sum=9+7+2=18

sum=9

So print 9

Input:

First line of input cotains T denoting number of test cases

Next T lines contains an integer N

Output :

Print T new Lines sum of digits of a number until single digit

Constraints :

1<=T<=30

1<=N<=106

Sample Input
3
123
987
85
Sample Output
6
6
4
Time Limit: 2
Memory Limit: 256
Source Limit:
Editor Image

?