Euler problem number #4

前端 未结 14 2030
萌比男神i
萌比男神i 2021-01-03 11:00

Using Python, I am trying to solve problem #4 of the Project Euler problems. Can someone please tell me what I am doing incorrectly? The problem is to Find the larg

14条回答
  •  无人及你
    2021-01-03 11:38

    The other advice here is great. This code also works. I start with 999 because we know the largest combination possible is 999*999. Not python, but some quickly done pseudo code.

    public static int problem4()
        {       
        int biggestSoFar=0;
            for(int i = 999; i>99;i--){
                for(int j=999; j>99;j--){
                    if(isPaladrome(i*j))
                       if(i*j>biggestSoFar)
                            biggestSoFar=i*j;
                }
            }
            return biggestSoFar;    
        }
    

提交回复
热议问题