When playing a lottery of 6 numbers and that numbers must be between 1 to 40, it is almost impossible to win it and here is why;
Supposedly you are to choose 6 numbers out of 40 numbers. You might thinnk that you have a 6/40 chance of winning but NO. Let us assume that the 6 numbers are represented by the lines bellow.
When picking a number between 1 to 40, your option will get lesser and lesser as you choose that number for example - when your picking your FIRST number you have 40 numbers to choose from, but now when you are picking your SECOND number you only have 39 numbers to choose from (because from the 40 numbers you already choose 1 of them as your FIRST number thus leaving you with 39 options left. ). Same thing happens as you choose your 3rd number leaving you with 38 options left and so on and so fort.
Thus our diagram now becomes;
Meaning the total number of possible combination when you choose 6 numbers out of 40 numbers are 40x39x38x37x36x35. Solving for the total possible outcome we have;

Meaning there are more than 2 Billion of possible out come.
And since you need 6 correct numbers, there are also many combination that can be made using your six winning numbers, because your 6 numbers don't have to follow a certain order and they can be interchanged. Therefore same with what we did above when arranging the order of the 6 numbers, there are 6 possible numbers that can be placed in the FIRST place, 5 possible numbers in the SECOND PLACE (since you already choose 1 out of the 6 numbers and you already put it in the first place), same with the 3rd to 6th number.
Illustrating it we get.
Therefore there are 6x5x4x3x2x1 possible arrangement for our 6 correct numbers. Or;

Therefore there are 720 combinations of the 6 numbers that we choose, meaning if we have 6 numbers there are 720 ways to arrange it.
Assuming that our 6 numbers that we choose is correct, we can also say that we choosed 720 correct combination.
Therefore our chances of winning the lottery is 720 out of 2,763,633,600 possible combination.

Therefore we have a 1 out of 3,838,380 chance to win a lottery of 40 numbers. If the order is not specified.
But if there is a specific order needed then sadly we must choose 1 correct combition out of 2,763,633,600 possible choices.