Unique random numbers


#1

Hi everyone.

I can’t find this topic anywhere else, so I hope someone can help me.

I want to generate six UNIQUE random numbers between let’s say 1 and 100.

Using the ‘random integer from 1 to100’ works fine for one number. But when you generate six, there are sometimes duplicates and this shouldn’t happen.

Any idea on how to do this without a PhD in mathematics?


#2

Just create a list that holds generated random number. If the number exists, means you have to get another random


How to generate unique id number
#3

My procedure creates a list of random numbers, with these options

Minimum
Maximum
How many numbers
Repeat or unique numbers
Sorted or unsorted
Sort order ascending or descending

GenerateRandomNumbers_function.aia (15.0 KB)


How to create random number without repeating same number?
[Free] QuizMaker Extension
#4

Thank you guys. Your helpfulness if appreciated a lot!


#5

I have managed to use a list to generate six random numbers.

My problem is the results go into an unformatted local variable. I can get it displayed in a text box in this form (1 2 3 4 5 6)

How do I get it out of there so I can format it and place each individual number in its own text box?


#6

you might want to learn
How to work with Lists by Saj
How to work with Lists and Lists of lists (pdf) by appinventor.org
Taifun


#7

Here is a alternative method:

On initialization, create a list that includes 1 to 100
Next select random item from list and then remove from list

Above ensures that every time you get unique number


#8

That’s exactly what my procedure (above) does when you set the noRepeat parameter to TRUE.


#10

Hay John this was quite a good idea, it was useful for me, you said it right. Boys but what if we are gonna make a program to run and to show the number that are representing the personality of the person based on the numbers you choose, and then you have take all the data from https://www.sunsigns.org/angel-numbers/ to make a database and to put it in the program. The program is connected with database and it should run. What do you think?


#11

Yes It ideal number to connect database