The domain set has $n$ elements and co-domain set has 2 elements. So, each of the $n$ elements from domain has 2 choices in the function and thus we get $2^n$ total functions.
Now, we are given a condition that exactly 1 positive integer less than $n$ maps to 1. So, all others less than $n$ must map to 0. We can find this number in $^{n-1}C_1$ ways (all the mappings for these $n-1$ elements are fixed) and $n$ can be mapped to either 0 or 1, thus we get $2. (n-1)$ possible functions.