题目:Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.
For example, given n = 2, return 1 (2 = 1 + 1); given n = 10, return 36 (10 = 3 + 3 + 4).
Note: you may assume that n is not less than 2.
1 public class Solution { 2 public int integerBreak(int n) { 3 int result=0; 4 if(n==2) 5 result=1; 6 else if(n==3) 7 result=2; 8 else { 9 result = integerBreakHealper(n); 10 } 11 return result; 12 13 } 14 public int integerBreakHealper(int n) 15 { 16 int result=0; 17 if(n==2) 18 result=2; 19 else if(n==3) 20 result=3; 21 else if(n==4) 22 result=4; 23 else { 24 result=(3*integerBreakHealper(n-3)); 25 } 26 return result; 27 } 28 }
原文:http://www.cnblogs.com/HelloWorld-5/p/5413482.html