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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:27:31+00:00 2026-05-31T05:27:31+00:00

Given the number N, write a program that computes the numbers E1, E2, …En

  • 0

Given the number N, write a program that computes the numbers E1, E2, …En with the following properties:

1) N = E1 + E2 + … + En;
2) E1 * E2 * … En is maximum.
3) E1..En, are integers. No negative values 🙂

How would you do that ? I have a solution based on divide et impera but i want to check if is optimal.

Example: N=10

5,5        S=10,P=25
3,2,3,2    S=10,P=36
  • 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-31T05:27:32+00:00Added an answer on May 31, 2026 at 5:27 am

    No need for an algorithm, mathematic intuition can do it on its own:

    Step 1: prove that a result set with numbers higher than 3 is at most as good as a result set with only 3’s and 2’s

    Given any number x in your result set, one might consider whether it would be better to divide it into two numbers.

    The sum should still be x.

    • When x is even, The maximum for t (x – t) is reached when t = x/2 , and except for the special case x = 2, then it is greater than x, and for the special case x = 4, equal to x (see note 1).
    • When x is odd, The maximum for t (x – t) is reached when t = (x ± 1)/2.

    What does this show? Only that you should only have 3’s and 2’s in your final set, because otherwise it is suboptimal (or equivalent to an optimal set).

    Step 2: you should have as many 3’s as possible

    Now, as 3² > 2³, you should have as many 3’s as possible as long as the remainder is not 1.

    Conclusion: for every N >= 3:

    • If N = 0 mod 3, then the result set is only 3’s
    • If N = 1 mod 3, then the result set has one pair of 2’s (or a 4) and the rest is 3’s
    • If N = 2 mod 3, then the result set has one 2 and the rest is 3’s

    Please correct this post. The times when I was writing well-structured mathematical proofs is far away…

    Note 1: (2,4) is the only pair of distinct integers such that x^y = y^x. You can prove that with:

    x^y = y^x
    y ln(x) = x ln(y)
    ln(x)/x = ln(y) / y
    

    and the function ln(t)/t is strictly decreasing after its global maximum, reached between 2 and 3, so if you want two distinct integers such that ln(x)/x = ln(y)/y, one of them must be lower or equal to 2. From that you can infer that only (2,4) works

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

Sidebar

Related Questions

Write a program that reads numbers until you read the number 999 then the
I am looking for a sound algorithm that would randomly place a given number
I'm trying to complete an exercise to write a program that takes the following
My goal is to write a program that handles an arbitrary number of tasks
How can I write an algorithm that given a floating point number, and attempts
Suppose you want to write a program that implements a simple phone book. Given
I am trying to write a program that opens an arbitrary number of forms
I was given an assignment to write a program to print only even numbers
I want to write a multipaint application - a program that enables users from
I am trying to write a program that takes an input of of n

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.