The formula of the binomial theorem is as follows:
If we set a = b = 1, then this relation takes the following form:
or
Thus, the indicated sum equals 2^n.
Example
If n = 1, then C_1^0 + C_1^1 = 1 + 1 = 2
If n = 2, then C_2^0 + C_2^1 + C_2^2 = 1 + 2 + 1 = 4
If n = 3, then C_3^0 + C_3^1 + C_3^2 + C_3^3 = 1 + 3 + 3 + 1 = 8
Algorithm realization
Read the input value of .
scanf("%lld", &n);Compute and print the result, the value of 2^n.
res = 1LL << n;
printf("%lld\n", res);Python realization
Read the input value of .
n = int(input())Compute and print the result, the value of 2^n.
res = 1 << n
print(res)