Confused with loops and random numbers

I've been very confused on how loops work and how random numbers work. I want to make a loop that will end once 1000 is chosen. I want 1000 to be chosen from using a random number generator that choses 1 to 1000. If 1000 isn't chosen, it will go through and check the numbers and perform some event. After the event is performed, it will re loop until 1000 is chosen. I have no clue where to start and I've read multiple tutorials. Please help?
pseudo-code:


declare number_chosen;
do 
    number_chosen = random_number_between_1_and_1000
    if number_chosen is not 1000, then
         do stuff here
while number_chosen is not 1000

Topic archived. No new replies allowed.