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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:59:36+00:00 2026-05-23T14:59:36+00:00

We need to generate random numbers within a certain digit range with few restrictions

  • 0
We need to generate random numbers within a certain digit range with few restrictions 
e.g. For double digit range 11 - 99, the resultant output should not include all like numbers [11,22,33,44,...99] and multiples of 10 [20,30,40....90]

The resultant output should be [12,13,14,15,16,17,18,19,21,23,...98]

Note: This function should work seamlessly for other digit ranges also (e.g. 3 digit ranges spanning 101 – 999 and four digit ranges spanning 1001 – 9999)

We are having difficulties in identifying like numbers (e.g 11, 22, 33, 44, 55, 66, 77, 88, 99, 111, 222, 333, …., 3333 …)

EDIT1:

protected static List<Integer> fetchRandIntegers(int min, int max, int howMany, boolean randomize) {

    // We need to reverse minimum, maximum values for negative ranges
    if (min > max) {
        int tmp = min;
        min = max;
        max = tmp;
    }

    List<Integer> allNumbers = new ArrayList<Integer>();
    for (int i = min; i <= max; i++) {
        allNumbers.add(i);
    }

    if (randomize) {
    ...
    }

    return allNumbers;

}

  • 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-05-23T14:59:37+00:00Added an answer on May 23, 2026 at 2:59 pm

    To identify if integer i has all digits the same:

    • Convert i to string and compare the characters, or
    • Repeatedly modulo and divide by 10 and check if all modulos are the same

    with something like:

    public boolean hasAllDigitsSame (int i)
    {
        int a = i ;
        int m = a % 10 ;
        int mm = m ;
        while(a > 0)
        {
            m = a % 10;
            if (m != mm)
              return False ;
            a /= 10 ;
        }
        return True ;
     }
    

    To identify if integer i is a multiple of 10 (100, 1000):

    • Check if i modulo 10 is 0.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to generate random UNIQUE numbers within a range, how can I do
I want to generate random numbers within a range and the generated numbers should
Like my question, i need to generate random numbers that have identical pairs between
I know how to generate a single random number within a given range, a
I want to generate random numbers with a range (n to m, eg 100
I need to generate a controlled sequence of pseudo-random numbers, given an initial integer
I need to generate quickly lots of random numbers from binomial distributions for dramatically
I need to generate a vector of random float numbers between [0,1] such that
I need to generate random numbers from Binomial(n, p) distribution. A Binomial(n, p) random
I need to use random class to generate random numbers in a multi threaded

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.