I’m trying some online problems. I programmed how to solve the greatest palindrome product of 2 two-digit numbers. For example 91*99=9009. I managed to do it by using the recursive function but I wonder how can i do it using arrays like this one?
product[0]=9;
product[1]=0;
product[2]=0;
product[3]=9;
or if the computed product is 969;
product[0]=9;
product[1]=6;
product[2]=9;
Then I will output it starting from the last index to the first index then test if its equal to the original number.
EDIT:
My question is, how can i store the computed product to an array?
There’s no reason to solve that Project Euler problem using arrays. But if you’re fixated on it, then there is a simple algorithm to convert an array of digits into a number. Just do this:
It’s not the most efficient method, I know (@Nandkumar’s is faster), but it’s really really simple, that’s what I was aiming for.