views:

76

answers:

3

Hello, I am trying to figure out a way to show an advertisement 75% of the time. I currently have a random number that is selected from 1 to 100. if the random number occurs between 1 and 75 I show the AD. Is there a better way to implement this

+2  A: 

You could select a number between 1 and 4, and if it's 1 through 3 then show the ad. :) But otherwise, no. What are you having problems with?

musicfreak
+2  A: 

With this approach you're probably going to display the ad 75% of the time. If you want it strictly 75%, you can use a counter.

hexium
+2  A: 

You'll never be able to display an add exactly 75% of the time because, in order to determine 75% of something you need to know that value (in your case the number of displays). But if you know the number of displays then you must have shown the add in the past ;) Hope it makes sense.

What you are doing is fine; the add will be displayed with a probability of 75% on each display.

Victor Hurdugaci