scripting lottery


i am stuck with a question from a customer!

my customer wants a webpage with a button that show a random number between 0 and 4000.

but the script need to generate that numer one by one. so first click the first number, then the second number, then the thirth and then the last number.

and the total number cannot be higher then 4000.

can anyone build this for me? i need a html of php page that can do this?
Rik Van LierOwner bvbaAsked:
Who is Participating?
Flabio GatesCommented:
fixed the infinite loop: fiddle
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Sounds like you can just repeatedly call random with a ceiling of 4000, keeping track of all numbers returned for one session.

If a duplicate number comes back, just call random again.

Just keep a hash of numbers returned so far in one session, so you can do fast lookups + if you ever require expanding total numbers returned, all your de-dup (duplicating) code will just continue to work, as-is.
Flabio GatesCommented:
no PHP, just javascript and JQuery: fiddle
note warning re infinite loop
Flabio GatesCommented:
Question inactive
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.