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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:11:56+00:00 2026-05-31T13:11:56+00:00

Had a hard time coming up with a concise title for this. I’m sure

  • 0

Had a hard time coming up with a concise title for this. I’m sure there are terms for what I want to accomplish and there is no doubt a common algorithm to accomplish what I’m after – I just don’t know about them yet.

I need to break up a number into n pieces that are each a multiple of 50. The number is itself a multiple of 50. Here is an example:
Divide 5,000 by 3 and end up with three numbers that are each multiples of 50:

  • 1,650
  • 1,700
  • 1,650

I also would like to have the numbers distributed so that they flip back and forth, here is an example with more numbers to illustrate this:
Divide 5,000 by 7 and end up with 7 numbers that are each multiples of 50:

  • 700
  • 750
  • 700
  • 750
  • 700
  • 700
  • 700

Note that in the above example I’m not worried that the extra 50 is not centered in the series, that is I don’t need to have something like this:

  • 700
  • 700
  • 750 <— note the ’50s’ are centered
  • 700
  • 750 <— note the ’50s’ are centered
  • 700
  • 700

Hopefully I’ve asked this clearly enough that you understand what I want to accomplish.

Update: Here is the function I’ll be using.

var number = 5000;
var n = 7;
var multiple = 50;

var values = getIntDividedIntoMultiple(number, n, multiple)

function getIntDividedIntoMultiple(dividend, divisor, multiple)
{
    var values = [];
    while (dividend> 0 && divisor > 0)
    {
        var a = Math.round(dividend/ divisor / multiple) * multiple;
        dividend -= a;
        divisor--;
        values.push(a);
    }

    return values;
}
  • 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-31T13:11:57+00:00Added an answer on May 31, 2026 at 1:11 pm
    var number = 5000;
    var n = 7;
    
    var values = [];
    while (number > 0 && n > 0) {
        var a = Math.floor(number / n / 50) * 50;
        number -= a;
        n--;
        values.push(a);
    }  // 700 700 700 700 700 750 750
    

    Edit

    You can alternate Math.floor and Math.ceil to obtain the desired result:

    while (number > 0 && n > 0) {
        if (a%2 == 0)
            a = Math.floor(number / n / 50) * 50;
        else
            a = Math.ceil(number / n / 50) * 50;
        number -= a;
        n--;
        values.push(a);
    }  // 700 750 700 750 700 700 700
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had a hard time coming up with a title for this question, but
I had a hard time coming up with a title, so I hope this
Ok, I had a hard time coming up with a title, as you can
Apologies for the less than ideal title; had a hard time coming up with
I'm sure this is fairly easy, but I've kind of had a hard time
If this was previously talked about, I'm sorry, I had a hard time searching
I really had a hard time knowing what words to put into the title
I'm new to programming and have had a hard time understanding recursion. There's a
Sorry about the confusing title, I had a hard time describing the problem. I
Please forgive the awkward title. I had a hard time distilling my question into

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.