Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Generate Random Number between 1-50 without repeats

How can I generate Random Numbers from 1050 without repeats

Posted on Oct 2, 2015 3:39 PM

Reply
Question marked as Best reply

Posted on Oct 5, 2015 9:11 AM

Choose Utilities from the FInder's Go menu, open the AppleScript Editor, and run:


set the_numbers to {}

repeat until (count the_numbers) is 10 --change this number as needed; if this is greater than 50, the script won't finish

set the_num to random number from 1 to 50

if the_num is not in the_numbers then set the_numbers to the_numbers & the_num

end repeat

the_numbers


If you'd like to copy and paste the result into Numbers or another spreadsheet, add the following:


set the_string to ""

repeat with this_number in the_numbers

set the_string to the_string & this_number & return

end repeat

set the_string to items 1 thru -2 of the_string as string


(134319)

16 replies

Generate Random Number between 1-50 without repeats

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.