Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7809861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:34:03+00:00 2026-06-02T03:34:03+00:00

I need to create a completely random number for each user on my website

  • 0

I need to create a completely random number for each user on my website and insert it into a MySQL database. The numbers can never repeat and I don’t want to use MySQL AutoIncrement because I need a specific range. Say from 111,111 to 999,999,999,999. No higher or lower as of right now. I do have a specific reason for that range, incase you were wondering. I know I can use the unique feature on MySQL but that only prevents me from inserting duplicates. I was thinking of having 2 functions, one to generate the number, and another to check if that number is used. They would keep looping until they found a number that wasn’t used. I know how inefficient that is and how long it may take once majority of those numbers have been taken so that is why I have come here, for a better answer. What do you suggest I do because I am all out of ideas. Thanks for any help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T03:34:04+00:00Added an answer on June 2, 2026 at 3:34 am

    Assuming that we will make it possible to generate any value in the closed interval [111111,999999999999], then we merely need to find some integer that is relatively prime to

    999999999999 - 111111 + 1 = 999999888889
    

    This a composite number, with rather large factors {18181, 55002469}.

    So now build a simple, not terribly random (but surely adequate here) number generator that will generate a new pseudo-random integer from the last one chosen. Do that by a simple modular computation. Pick some number to start with, and another integer that is relatively prime to the factors listed above.

    N(1) = 111111111111
    N(i+1) = mod(N(i)*2803 + 4353454321 , 999999888889)
    

    You can repeat this process without cycling until you get very bored.

    Since you want the lower limit to be 111111, just add that value to every number when you use it. This procedure yields the following sequence:

    {111111111111, 448832453975, 81861723884, 462790945592, 207518059664, 677539248004, 147076609322, 260135161619, 163292472297, 713204080539, 115613316027, 68514277966, ...}
    

    You will add 111111 to every value to ensure that the lower limit is truly 111111, so the sequence that will be reported is just:

    {111111222222, 448832565086, 81861834995, 462791056703, 207518170775, 677539359115, 147076720433, 260135272730, 163292583408, 713204191650, 115613427138, 68514389077, ...} 
    

    The nice thing is all you need to be able to do is store the last member of the sequence, and do modular operations on a number that will fit into a 64 bit integer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to Zkoss and i need to create completely new css theme
I need create custom dialog and put JPanel into it. Is it possible?
I need create clone repository. but I do not know where can I get
I need create a document word with Java. And I ask, how can I
I'm creating a script which creates a random security number for a user, and
I need to create a website launcher application for Windows Phone 7. Basically, it
I'm completely stuck and need your help... I've created a webservice stub with jaxb
I need create a server side game loop, the problem is how to limit
i need create an email list sending to many emails. what is best solution
i need create a variable with parent subclass. Example: Parent Class <?php class parentClass

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.