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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:00:27+00:00 2026-05-17T19:00:27+00:00

i can generate random number between two numbers in c using this.. arc4random()%(high-low+1)+low; then

  • 0

i can generate random number between two numbers in c using this..

arc4random()%(high-low+1)+low;

then now my requirement is…i want to make a number rare….thats mean if

high=5,
low=1,
and rare=3,

than 3 will be appeared much rarely than 1,2,4 and 5…

Thanks

  • 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-17T19:00:28+00:00Added an answer on May 17, 2026 at 7:00 pm

    You can use tables to calculate your final roll, similar to how pen and paper RPGs do this same type of calculation:

    Roll 1 D 21 (easily possibly w/ code).

    • If you get 1-5, it counts as a 1
    • If you get 6-10, it counts as a 2
    • If you get 11-15, it counts as a 4
    • If you get 16-20, it counts as a 5
    • If you get a 21, it counts as a 3

    The advantage to this option is you get a strong sense of the exact probabilities you are dealing with. You can get a feeling of exactly how rare or common each number is, and you get fine-grained control of how common each number is, in comparison to the other numbers.

    You could also use fractions to generate the table. Use the Least Common Multiple to determine a common base. That base is the max random number size you will need. Then, put all the fractions in like terms. Use the resulting numerators to determine the size of the range for each number in the table.

    With this automated solution, the input numbers are very easy to understand in relation to each other. E.g:

    • 1/4 for 1
    • 1/4 for 2
    • 1/4 for 4
    • 1/5 for 5
    • 1/20 for 3

    This would generate a table like so:

    LCM = 20

    • 1-5 = 1 (like terms – 5/20)
    • 6-10 = 2 (5/20)
    • 11-15 = 4 (5/20)
    • 16-19 = 5 (4/20)
    • 20 = (1/20)

    Some more on LCM: http://en.wikipedia.org/wiki/Least_common_multiple

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

Sidebar

Related Questions

In my app, I handle numbers as BigDecimal and store them as NUMBER(15,5). Now
i wrote a php script to generate random values between 1 and 99999999999999999999 (that's
I'm a (near complete) beginner, and this is my first foray into encryption -
The accepted answer to this question , and a similar discussion at work today
I have a website that grabs a random entry from a database and displays
I am writing a numerical program that should be somewhat fast, and is also
I've been working on generating Perlin noise for a map generator of mine. The
I've been following a tutorial from a recent edition of the Linux Journal which
When users register an account they get an email with a verification code that
I have a state machine design that needs to support playback. We have states

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.