How to generate Lottery Numbers on the Commodore 64

Channel:
Subscribers:
29,700
Published on ● Video Link: https://www.youtube.com/watch?v=1IhWEGqXNgE



Category:
Guide
Duration: 10:43
796 views
18


In this video I'll demonstrate how to draw random lottery numbers on a Commodore 64. The secret sauce here is not only the RND function to generate random numbers, but also two loops inside each other that prevent the same number from coming up more than once.

Here's the lottery generator code:

10 x=rnd(-ti)
20 for i=1 to 6
30 rn=int(rnd(1)*49)+1
40 for j=1 to i
50 if n(j)=rn then 30
60 next j
70 n(i)=rn
80 next i
100 print
110 for i=1 to 6
120 print n(i);
130 next
140 print
199 end

To adapt this listing to match your local lottery, change line 20 to the amount of numbers to be drawn from your pool (6 in my example), and change the value in line 30 to match the size of your pool (49 in my example).

Any questions, please let me know below. Happy retro hacking!


SUPPORT MY PROJECTS
=====================
https://patreon.com/versluis
https://streamlabs.com/wpguru


LISTEN ON SPOTIFY
=================
3D Podcast
https://open.spotify.com/show/4IIh2WPBMRbjct6wdrGcTH?si=Tb7qVvEeQ2GxHpVjahGZNQ

Tech Podcast
https://open.spotify.com/show/3MSMNOruDorce08roxUy85?si=63KfmlDFTT-U1HzpNaa8pw







Tags:
Commodore
BASIC
C64
C128
Plus4
Lottery
Lotto
Random