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

  • SEARCH
  • Home
  • 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 8658955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:53:23+00:00 2026-06-12T15:53:23+00:00

In my program I need to produce many large sequences of random integers. I

  • 0

In my program I need to produce many large sequences of random integers.

I know that I can just use the Random object to create the sequence, store that sequence in a list or an array and then query it for the i’th element when it needed but as the sequence can be very long (1M elements) and I have many different sequences I wish to know if I can store only the seed of each sequence and do something like:

public static int getIthNumber(int seed, int i){
    Random r = new Random(seed);
    for (int j=0; j< i-1; ++j) r.nextInt();
    return r.nextInt();
}

but without the overhead of the loop..

  • 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-12T15:53:24+00:00Added an answer on June 12, 2026 at 3:53 pm

    If you need random access you can avoid using a proper sequence.

    public static int getIthNumber(int seed, int i){
        return new Random(seed * 10123457689L + i * 101111).nextInt();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a program that produces an executable slideshow. So I need
It's well-known among teachers that some people can program and some can't. They just
I am working on a program and need ot know how I would read
I need a program that checks if the difference between all pairs of elements
I need my program to create and edit a config file, which would contain
I need a program that reads from multiple files and displays a report based
I have command-line program that do a lot of work and produce a lot
For my project, I need to make a program that takes 10 numbers as
I am writing a program where there are worker threads which create random numbers
In my program I need to programmatically configure an ApplicationContext. Specifically, I have a

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.