Raised This Month: $ Target: $400
 0% 

Random numbers without repeating


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
KiLLeR.
Senior Member
Join Date: Jul 2014
Location: Bulgaria
Old 05-02-2016 , 11:32   Random numbers without repeating
Reply With Quote #1

PHP Code:
for(new i=0i<5i++)
{
    
num[i] = random_num(110);

So, how to retrieve 4 random numbers between 1 and 10, but without repeating.

I can use something like:
PHP Code:
if((num[0] == (num[1] | num[2] | num[3] | num[4] | num[5])) || (num[1]  == (....)))
{
    
// retrieve a new random number

But I think, that this isn't the most efficient way (even if it works).

Last edited by KiLLeR.; 05-02-2016 at 12:10.
KiLLeR. is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:43.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode