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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:48:58+00:00 2026-05-20T19:48:58+00:00

In the following interview question : Given a number n, give me the numbers

  • 0

In the following interview question :

Given a number n, give me the numbers
(among 3..5 and an even number of
numbers) whose adding would return the
original number. The resulting numbers
should be as balanced as possible,
meaning that instead of returning 3
and 5, for instance, return 4 and
4. Ex:

7 = 3 + 4
16 = 4 + 4 + 4 + 4 rather than 3 + 5 + 4 + 4
24 = 12 + 12 or 6 + 6 + 6 + 6

I thought of the following method:

splitnumber(int n)
{
    //check if the number is even
    if(n%2==0)
    {
        print(n/2,n/2);
        //check if x=2^m multiple exists or
        // not..like 4,8,16 etc
        print (n/x...n/x);
    }
    else //else if the no is odd... this part is incomplete
    {
        if(n-3>0)
        {
            print (3);

        }

        n-=3;
        if(n>0)
        {
            if (n>5)
            {
                print(3)
                n-=3;
            }
        }
    }
}

but still I am not able to complete all the cases… How should I check when the answer has unbalanced solution??

  • 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-20T19:48:59+00:00Added an answer on May 20, 2026 at 7:48 pm
    if (n < 4) print n;
    else
        switch (n % 4)
            case 0: *print n/4 4's*
            case 1: *print n/4 - 1 4's* print 5
            case 2: *print n/4 - 1 4's* print 3 print 3
            case 3: *print n/4 4's* print 3
    

    Slightly inefficient implementation in C#

    if (n < 4) Console.WriteLine(n);
    else
        switch (n % 4)
        {
            case 0:
                Console.WriteLine(String.Join(" ", new string('4', n / 4).ToArray()));
                break;
            case 1:
                Console.WriteLine(
                    (String.Join(" ", new string('4', n/4).ToArray().Skip(1)) + 
                    " 5").TrimStart());
                break;
            case 2:
                Console.WriteLine(
                    (String.Join(" ", new string('4', n/4).ToArray().Skip(1)) + 
                    " 3 3").TrimStart());
                break;
            case 3:
                Console.WriteLine(String.Join(" ", new string('4', n/4).ToArray() + 
                    " 3"));
                break;
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently saw an interview question asking the following: Given a 32 bit number,
I got following question on an interview: Given a table of natural numbers with
I was given the following as an interview question: class A { public: void
I was asked the following Question: How would you store the data given below(which
Recently in a job interview I was asked this following question (for Java): Given:
I was asked the following question during phone interview I had: Given the following
I recently encountered the following interview question: How can you multiply a number by
I came across this post , which reports the following interview question: Given two
Could your please help me with following interview question. Given function ‪ Sleep(int seconds)
A friend of mine was asked the following question a Yahoo interview: Given a

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.