﻿

# Lottery

I'm sure you'll be familiar with the National Lottery - it's been running for nearly 20 years. A large machine picks six balls out of a set of balls numbered from 1 to 49. Making such a machine is beyond most of us, but we can simulate one with a computer program.

## Commands

Here is a reminder of the commands you might need for this task.

• FOR - repeats a section of your program a number of times - e.g. FOR N = 1 TO 10 will repeat 10 times, counting with N from 1 to 10.
• NEXT - goes after FOR, at the end of the section that you want to repeat.
• WHILE - repeats a section of your program, but while a particular condition exists, rather than for a fixed number of times, e.g. WHILE x < 10 would repeat something until x reached 10 or more.
• WEND - goes after WHILE, at the end of the section that you want to repeat.
• RND(1) - gives you a random number from 0 to 1, which can be printed or assigned to a variable, e.g. x = RND(1). Look at the page on random numbers to see how you can scale this number into the right range.

Your task is to simulate a lottery machine and pick six random numbers from 1 to 49. Your program should:

1. pick six random numbers from 1 to 49 (inclusive)
2. display the six numbers so that they are separate and easy to read

The minimum output is the six numbers, but you can add extra text to make your program easier to understand.

### Extension

If you run your program a few times, you'll probably realise that it's not like a real lottery machine. A real lottery machine would never pick the same number twice, for example, because once you've drawn a ball, it's not there to be drawn again. The lottery results are also normally read out in numerical order.

See if you can get your program to:

• not allow any duplicates - i.e. only allow each number to be drawn once per run.
• sort the numbers before displaying them - you might need to do a bit of research on how to do this if it wasn't explained in the lesson.