Shop Learn
random numbers — Parallax Forums

random numbers

I am trying to write a program to randomize numbers from 1 to 70 without success. Does someone have such a program? Thanks


  • Tracy AllenTracy Allen Posts: 6,554
    edited 2021-02-10 17:55

    I see you also asked this question about the Propeller 1. The same logic applies for the Stamp, except the Stamp will use a 16-bit word.

    flip VAR Word
      RANDOM flip
      DEBUG DEC5 flip,  "   ", DEC2 flip // 70 + 1,CR
      PAUSE 100

    That will play out the same series of pseudorandom numbers each time you start the program. For variation, seed the value of flip at the start.
    Is that what you want by "randomize numbers from 1 to 70"? That could also mean you want all the numbers 1 to 70 inclusive, in a random order.

  • Syntax error: I'd written flip=RANDOM flip, but it should be simply RANDOM flip. Modified accordingly in my previous post.

    If you do want a table of values from 1 to 70 in random order, we first have to know the destination. There is enough scratchpad RAM in the BS2P series. Or eeprom in the other Stamps, so long as the values don't change often? Or some external memory or device?

  • It' a start. But I am trying to generate 6 non-repetitive two decimal random numbers from 1 to 52, so I can play Lotto.

Sign In or Register to comment.