Get random number without repeating

how to get random numbers without repeating.

I tried something like this but numbers are repeating



(Updated/Edited) - I posted some blocks without testing and those blocks are not working, sorry for that. I edited this post.
This works perfectly…

Mark as Solution if found helpful… :slightly_smiling_face:


Did you even try your code, as both looks weird to me…

1 Like

I tried this method in my real project and it’s not working.

I used Method 2 in my random generator app for remove used letters for scattergories.

1 Like

@sonumohammad333 Your 1st method looks strange​:roll_eyes:, and I just tested the second method, it is not working.

It will only work at first removal and on a couple of them it will remove the wrong index number and in the end it will show wrong list length


What should i do next.:slightly_smiling_face:


Procedure to generate lists of numbers with these options:

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


What do i need to change in this blocks ?

What you are doing wrong is selecting random numbers from a fixed range (example 1 to 10, always).

You need to change that range every time a number is selected to create a “pool” of possible numbers. Example : Pool is 1,2,3,4,5,6,7,8,9,10. If 4 is selected, then remove it from the pool and next time it will not be possible to select it again.

We all showed you up there how to do that. You will have to adapt it to your project.


I edited my post. Now it works perfectly.

1 Like

project.aia (12.2 KB)

I am unable to adapt it according to my project,:face_with_head_bandage:here is my file.

When that happens, it means you have to start the whole procedure from scratch. I would recommend that, since your procedure for selecting random numbers is not what you really need.

1 Like

I am creating a quiz app with the help of quize extension, and I want that when the answer to the question arises from this extension, I want to show the numbers around that answer in four buttons, of which 1 will be the correct answer which will be generated by the extension and the remaining 3 options will be the numbers around that answer.

you might want to look into this App Inventor Tutorials and Examples: Advanced Features | Pura Vida Apps

1 Like

you might want to look into this App Inventor Tutorials and Examples: Advanced Features | Pura Vida Apps

I generated 4 possible answers, Now I have to show 4 options without repeating numbers, i am confused how can i do like this. :expressionless:

you already received several good answers…
start reading here again and implement what @Italo said