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 7772383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:52:40+00:00 2026-06-01T16:52:40+00:00

I want to generate atleast 1000 unique random numbers with 10 digit using javascript

  • 0

I want to generate atleast 1000 unique random numbers with 10 digit using
javascript in a loop. Is this possible? Or is Javascript a wrong thing to do this?

UPDATE: How will you be sure that duplicates are not created?

  • 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-01T16:52:42+00:00Added an answer on June 1, 2026 at 4:52 pm

    Here’s how I would do it:

    var arr = [],
        track = [],
        min = 1000000000,
        max = 9999999999,
        qty = 1000,
        ii = 0,
        rnd;
    
    while (ii < qty) {
        rnd = Math.floor(Math.random() * (max - min + 1)) + min;
        if (!track[rnd]) {
            arr[ii] = track[rnd] = rnd;
            ii += 1;
        }
    }
    

    Here’s a working example: http://jsfiddle.net/mTmEs/

    Now, if something went awry with Math.random and for some reason it were to generate a lot of duplicates, this code could take a long time to complete. I don’t think there is any way around this kind of potential problem though when you’re talking about large quantities of unique random numbers.

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

Sidebar

Related Questions

I want to generate 25 unique random numbers and list them in a console.
I want to generate random numbers manually. I know that every language have the
I want to generate unique code numbers (composed of 7 digits exactly). The code
Let's say I have a class of 30 students and want generate every possible
I want to generate random colours which can be attractive in pie charts.I have
I'm using this to export records to CSV format. But i want to give
I'm trying to generate several random doublesbetween 0 and 1. This is the code
I want to generate several SQL statements based on a column list using the
This is a JavaScript/Ajax webpage (also using jQuery). I have a nested structure I
I want to generate a thumbnail preview of videos in Java. I'm mostly JMF

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.