Post Reply 
Random Integers, No Repeats
08-09-2023, 04:59 PM
Post: #7
RE: Random Integers, No Repeats
(08-09-2023 04:54 AM)Joe Horn Wrote:  
(08-09-2023 02:30 AM)lrdheat Wrote:  I cannot remember how to generate random numbers from x to y with no repeats…anybody know how to accomplish this using the RANDINT or randint command?

If you don't mind using an undocumented but stable CAS function, rand(X,Y,Z) returns X random integers between Y and Z without repeats. Example: rand(10,50,59) returns all 10 integers between 50 and 59 in random order. It's faster than creating an array and then shuffling it. rand(10000,1,10000) takes only 0.0072 seconds on a G2 Prime. Although it's a CAS function, it also seems to work in Home and in non-CAS programs.

Hey Joe, this is a great function. Do you happen to know what kind of seed is rand using?
Thanks and regards
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Random Integers, No Repeats - lrdheat - 08-09-2023, 02:30 AM
RE: Random Integers, No Repeats - Joe Horn - 08-09-2023, 04:54 AM
RE: Random Integers, No Repeats - nickapos - 08-09-2023 04:59 PM
RE: Random Integers, No Repeats - Joe Horn - 08-09-2023, 05:10 PM
RE: Random Integers, No Repeats - lrdheat - 08-09-2023, 01:24 PM
RE: Random Integers, No Repeats - Joe Horn - 08-09-2023, 05:31 PM
RE: Random Integers, No Repeats - nickapos - 08-09-2023, 06:04 PM
RE: Random Integers, No Repeats - parisse - 08-09-2023, 06:09 PM



User(s) browsing this thread: 1 Guest(s)