Powerful Number
Practice
1 (1 votes)
Data structures
Brute force
Math
Modulus arithmetic
C++
Number theory
Problem
69% Success 189 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Touka is fan of big numbers, so when her friend kuroko gives her a positive number \(N\) she calculates \(M=2^N\)(2 raised to power N) and tell it to him .But since \(M\) can be very large so it is very difficult for her to tell it to kuroko. So she decides to calculate the sum of digits of \(M\) till she gets a single digit number and tells it to kuroko.
Touka is very tired of the calculation and needs your help to calculate it for her.
Her friend kuroko asks her \(T\) queries.
In each query you will be given \(N\) as input.
Print the answer reqired in each query.

Example

Let's assume that \(N\)=6 then \(M\)\(2^6\) = 64.

Now 6+4=10. Since it's still not a single digit so we add digits of 10 i.e 1+0=1, which is the required answer.

Function Description

Complete the solve function provided in the editor. This function takes the following 1 parameter and returns the sum of digits of \(M\) untill its a single digit number.

  • \(N\): Represents an integer denoting \(N\).

Input format

Note: This is the input format that you must use to provide custom input (available above the Compile and Test button).

  • The first line has an integer \(T\) denoting the number of test cases.
  • For each test case:
    • The only line has an integer \(N\).

Output format

Print \(T\) lines each corresponding to the answer to each query.

Code snippets

Code snippets are written in languages C, C++, Java, Python.

Constraints

\(1 <= T <= 100\)
\(0 <= N <= 100000\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
3 votes
Tags:
MathematicsModular arithmeticEasy
Points:20
2 votes
Tags:
Modular arithmeticSimple-mathEasy
Points:20
1 votes
Tags:
Easy