Sum of all sub-sequences of a number
Submissions: 1153   Accuracy:

48.75%

  Difficulty: Basic   Marks: 1

Given a number as integer s, find the sum of all the elements present in all possible subsequences of s.

Input:
The first line of the input contains an integer denoting the number of test cases. For each test case, there is a integer s as input.

Output:
For each test case, the output is an integer displaying the sum of all possible subsequences of s.

Constraints:
1<=T<=100

1<=S<=10^6

Example:
Input:

1
123
Output:
24

Explanation:
All possible sub-sequences are 1, 2, 3, {1, 2}, {2, 3}, {1, 3}, {1, 2, 3} which add up to 24.

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Vanshika
Author: Vanshika_pec


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.