Break The Integer Problem Statement

Given an integer N, the task is to divide this integer into 'K' positive parts (where K ≥ 2) such that their sum equals N. The objective is to maximize the product of these 'K' parts.

Input:

The first line contains an integer 'T', representing the number of test cases.
Each of the next 'T' lines contains a single integer 'N'.

Output:

For each test case, return the maximum product achievable by dividing 'N' into 'K' parts.

Example:

Input:
T = 2
4
10
Output:
4
36
Explanation:

For N = 4, breaking it into parts [2, 2] gives product 4.
For N = 10, breaking it into parts [3, 3, 4] gives product 36.

Constraints:

  • 1 ≤ T ≤ 11
  • 2 ≤ N ≤ 55
  • Time Limit: 1 sec
Be the first one to answer
Add answer anonymously...
Info Edge Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter