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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:22:46+00:00 2026-06-17T22:22:46+00:00

Provided the below values start value = 1 End Value = 20 Interval =

  • 0

Provided the below values

  1. start value = 1
  2. End Value = 20
  3. Interval = 5

I have been provided a number 6. I have to find the range of numbers in which the number 6 falls say now the answer is 6-10.

If the given number is greater than the end value then return the same number.

Is there any formula so that i can generate the range for the number?

UPDATE

I tried the below solution, But it is not working if the range interval is changed,

 $end_value = $start_value + $range_interval;

// we blindly return the last term if value is greater than max value
if ($input_num > $end_value) {
  return '>' . $end_value;
}

// we also find if its a first value
if ($input_num <= $end_value && $value >= $start_value) {
  return $start_value . '-' . $end_value;
}

// logic to find the range for a given integer
$dived_value = $input_num/$end_value;

// round the value to get the exact match
$rounded_value = ceil($dived_value);

$upper_bound_range = $rounded_value*$end_value;

$lower_bound_range = $upper_bound_range - $end_value;

return $lower_bound_range . '-'. $upper_bound_range;
  • 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-17T22:22:47+00:00Added an answer on June 17, 2026 at 10:22 pm

    In (c-style) pseudocode:

    // Integer division assumed
    rangeNumber = (yourNumber - startValue) / rangeLength;
    lower_bound_range = startValue + rangeNumber*rangeLength;
    upper_bound_range = lower_bound_range + rangeLength-1;
    

    For your input:

    rangeNumber = (6-1)/5 = 1
    lower_bound_range = 1 + 5*1 = 6
    upper_bound_range = 10
    

    and so range is [6, 10]

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

Sidebar

Related Questions

My web designer has provided me with updated fonts/icons that have been added to
I have several records in a database that have Start and End Dates 09/15/2011
I have been using the block of code below to supposedly stop sql injections.
I have an xml file which looks like the below example <Ids> <Id> <set>ai</set>
I have a frequency and a time range with which the frequency has to
I'm using the code provided below to display time and date. can anyone help
I read this question in stackoverflow. The excerpt answer provided by bbum is below:
I'm trying to find a subpalindrome in Java. But the below code doesn't provide
I have types provided in a library I cant modify, such as this: namespace
I have an array of nearly sorted values 28 elements long. I need to

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.