Basics of Permutations and combinations I am confused when to use $n^r$ or $r^n$ formula but what I see is that the number of ways can be explained by either formula so when to apply which formula,please clarify?
 A: $n^r$ captures the number of ways to arrange $r$ objects into a line when you have $n$ options at each position. On the other hand, $r^n$ will capture the number of ways to arrange $n$ objects into a line with $r$ options at each position. As you can see, there's not a fundamental difference between the two formulas because they're solving the same kind of counting problem. The difference is only in how many objects are in the arrangement (which is the power) and how many options you have at each position of the arrangement (which is the base). 
Crucial to these is that repetition is allowed, meaning you can use the same object in multiple positions, and that order matters. The formula is a consequence of what's often known as the 'multiplication principle'. 
As an example of their differences, let $r = 3$ and $n = 2$. Then $n^r$ can be seen as the number of binary strings of length 3 (000, 001, 010,  etc.) where as $r^n$ can be seen as the number of ternary strings of length 2 (00, 01, 02, 10, etc.). 
A: $n^r$ is the number of functions from a set of size $r$ to a set of size $n$:
$$
n^r=\overbrace{\ \ \ \ \ \ n\ \ \ \ \ \ }^{\text{choices for element }1}\times\overbrace{\ \ \ \ \ \ n\ \ \ \ \ \ }^{\text{choices for element }2}\times\,\cdots\,\times\overbrace{\ \ \ \ \ \ n\ \ \ \ \ \ }^{\text{choices for element }r}
$$
$n^r$ is also the number of ways to fill each of $r$ slots with one of $n$ objects where any of the objects can be reused.
If you think about it, you can see that these are saying the same thing.
A: I like to think a number lock when I think that formula. I.e. if you have a lock with four dials with numbers from 0 to 9, then the number of possible combinations is $10^4$, because there are four dials and each have 10 numbers.
