Number of tried for a favorable result I am new to statistics so I apologize for the simplicity of my question. 
I have a bag with 27 numbers inside; I will pull one number out until I get number 17. THe numbers will be returned to the bag after every try so the prob of success will always be 1/27.
I am trying to determine on average how many pulls I will need.  
 A: On average, you need 27 tries.
A: It is easier to think backwards. What is the chance of NOT choosing 17? That chance is 26/27. What is the chance of not choosing 17 twice in a row? The answer is (26/27)(26/27). How about three times in a row?  The answer is (26/27)(26/27) *(26/27). More generally, the answer is (26/27)^K, where K is the number of times you try and "^" means "to the power of". You can compute that probability for various values of K, and find a value of K that gives an answer close to 0.50. 
A: Harvey explained the logic.  But the name of the distribution you're interested in is the geometric distribution.
A: Edit: I made a presumption before where after 27 tries it would then stop searching thus giving a bias on the results
# Number of repeats
iters = 10000
results = rep(0,iters)
# Ball to search for
searchNumber = 27

for(i in 1:iters) {
    # A random permutation:
    balls = sample(1:27,iters, replace=T)

    # Number of times picking a ball
    tries = 1

    while(tries<iters) {
        if(balls[tries] == searchNumber) {
            results[i] = tries
            break
        }
        tries = tries + 1
    }
}

hist(results, breaks=100, col="blue")
mean(results)

Edit: with a mean / average of around 27
Edit: In my example we are looking for 27 but the results are the same, it could be any number between 1-27
