ankit-and-numbers-8

Ankit has a set of numbers and has recently studied set theory. He has created a power set of this set and is writing a program to compute sum of all elements of all the subsets in power set. 
Power set of a set S is defined as set of all possible subsets of S.

Set S consist of all the number from 1 to N.

You need to calculate this sum for a given n.

Example: 

Given N=3,
S={1,2,3}
P(S) = {{1}, {2}, {3}, {1,2}, {1,3}, {2,3}, {1,2,3}}
answer = (1)+(2)+(3)+(1+2)+(1+3)+(2+3)+(1+2+3)
         = 24

Input
First line has T, the total number of test cases.
The next T lines contains a number N in each line.  

Output
T lines giving answer as defined in the question for each N.  

Constraints
1 ≤ T ≤ 42
1 ≤ N ≤ 42

SAMPLE INPUT
1
3

SAMPLE OUTPUT
24

Difficulty: EASY
Tags: Fundamentals

Starter code:

Solutions:
t=int(input())
while t:
	t-=1
	n=int(input())
	power=2**(n-1)
	su=0
	for j in range(0,n):
		su+=(j+1)*power
	print(su)


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''

def mySet(n):
	power=2**(n-1)
	result=0
	for i in range(n):
		result += (i+1) * power
	return result

T = int(input())
for i in range(T):
	N = int(input())
	print(mySet(N))
	
	


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''

t=eval(input(''))

while t>0:
	n=int(eval(input('')))
	pp=1<<n-1
	cnt=0
	for i in range(n+1):
		cnt+=pp*i
	print(cnt)
	t-=1


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'
t=eval(input())
while t>0:
	a=eval(input())
	print(pow(2,a-1)*(a*(a+1)/2))
	#b=[0]*a
	'''
	for i in range(1,a+1):
		z= '{0:042b}'.format(i)

		for i in z:
			if(i==1)
				print "hi"
		print 
		'''
	t=t-1
	


if __name__=='__main__':
	T = int(input())
	for i in range(0,T):
		n = int(input())
		print(((n*(n+1))//2)*(2**(n-1)))


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
if __name__ == '__main__':
	cases = int(input())
	start = 1
	while start <= cases:
		number = int(input())
		no_of_occurances = 2 ** (number - 1)
		sum_of_numbers = (number * (number + 1)) / 2
		answer = no_of_occurances * sum_of_numbers
		print(answer)
		start = start + 1



#-------------------------------------------------------------------------------
# Name:        module1
# Purpose:
#
# Author:      sumit.jain
#
# Created:     30/09/2014
# Copyright:   (c) sumit.jain 2014
# Licence:     <your licence>
#-------------------------------------------------------------------------------

#def main():
t=eval(input());
for i in range(1,t+1):
	x=eval(input());
	print((x*(x+1)/2)*pow(2,x-1))


#if __name__ == '__main__':
 #   main()


#!/usr/local/bin/python2.7
data=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,]
def solve(n):
	global data
	if data[n]>0:
		return data[n]
	if(n==1 or n==0):
		return 1
	data[n] = 2*solve(n-1) +  n*(1<<(n-1))   
	return data[n]


N = int(input())

for i in range(N):
	u = int(input())
	print(solve(u))



t=eval(input())
for i in range(t):
	n=eval(input())
	p=2**(n-1)
	s=0
	for x in range(n):
		s+=(x+1)*p
	print(s)


t = eval(input())
for i in range(0, t):
	n = eval(input())
	print(n * (n + 1) * (2 ** (n - 1)) / 2)


t=int(input())
while t:
	t-=1
	n=int(input())
	power=2**(n-1)
	su=0
	for j in range(0,n):
		su+=(j+1)*power
	print(su)


#!/usr/local/bin/python2.7
data=[0 for x in range(44)]
def solve(n):
	global data
	if data[n]>0:
		return data[n]
	if(n==1 or n==0):
		return 1
	data[n] = 2*solve(n-1) +  n*(1<<(n-1))   
	return data[n]


N = int(input())

for i in range(N):
	u = int(input())
	print(solve(u))



'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''

def main():
	import sys
	f = sys.stdin
	#f = open("ankit-and-numbers-8.txt")
	
	T = int(f.readline())
	
	for dummy_1 in range(T):
		N = int(f.readline())
		ans = 2**(N-1)*sum(range(1,N+1))
		print(ans)

main()


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
t=eval(input())
for i in range(t):
	n=eval(input())
	p=2**(n-1)
	s=0
	for x in range(n):
		s+=(x+1)*p
	print(s)


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'
t=eval(input())
while t>0:
	a=eval(input())
	print(pow(2,a-1)*(a*(a+1)/2))
	#b=[0]*a
	'''
	for i in range(1,a+1):
		z= '{0:042b}'.format(i)

		for i in z:
			if(i==1)
				print "hi"
		print 
		'''
	t=t-1
	


for _ in range(int(input())):
	n=int(input())
	if n==1:
		print("1")
	else:
		a = (n*(n+1)*2**(n - 2))
		print(a)


for i in range(eval(input())):
	n=eval(input())
	powr=2**(n-1)
	sum=0
	for j in range(1,n+1):
		sum+=(j)*powr
	print(sum)


def sub(t):
	a = 0
	while a < t:
		n = int(eval(input()))
		print((int(n*(n+1)/2*pow(2,n-1))))
		a = a+1


def main():
	count = 0
	T = int(eval(input()))
	sub(T)

if __name__ == '__main__':
	main()


import math

    
if __name__ == '__main__':
	T = eval(input())
	
	while T:
		T-=1
		n=eval(input())
		S=0
		
		
		for i in range(1,n+1):
			S=(S+i*pow(2,n-1))
		
		    
		print(S)     


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'

t=int(input())
if t>=1 and t<=42:
	for i in range(t):
		n=int(input())
		print((2**(n-1))*(n*(n+1)/2))
		


t=int(input())
while t>0:
	t=t-1
	n=int(input())
	if n==1:
		print(1)
	else:
		print(n*(n+1)*(2**(n-2)))


t=int(eval(input()))
while(t):
	t=t-1
	n=int(eval(input()))
	print((n*(n+1))/2 * 2**(n-1))


t=eval(input(''))

while t>0:
	n=int(eval(input('')))
	pp=1<<n-1
	cnt=0
	for i in range(n+1):
		cnt+=pp*i
	print(cnt)
	t-=1



for _ in range(eval(input())):
	n=eval(input())
	print(int(n*(n+1)*(2**(n-2))))


t=eval(input())
for i in range(0,t):
	n=eval(input())
	power=2**(n-1)
	sum=0
	for j in range(0,n):
		sum+=(j+1)*power
	print(sum)