Largest palindrome product - euler project

后端 未结 15 2036
广开言路
广开言路 2020-12-10 22:05

I was trying to solve project Euler problem 4 which is:

A palindromic number reads the same both ways. The largest palindrome made from the product of tw

15条回答
  •  攒了一身酷
    2020-12-10 22:43

    Well I am seeing a lot of things wrong here.

    • First of all you are using multiplication of 2 highest 3 digit numbers and then decrementing it to find palindrome. What you need to do according to question is to use variables having highest 3 digit no.s and then decrement them to check there resultant product.
    • Second for checking if the no. is palindrome you used an array to store it then used a loop to check it, I find it incorrect, as you could simply store the resultant no. in another integer variable by using the simple approach.(reverseNum * 10 + (num % 10) )

    And I am seeing a correct code already posted by a user (ROMANIA)

提交回复
热议问题