- Split the string to 5 characters (well, the 5 digits as per the question)
- Change to integers
- Get the products of those 5 digits
- Compare the largest product and current product
- Display the largest product at the end
Certain conditions that I can put in as I read around the Internet websites are "If it involves digit 0, skip to next as the product will always be 0" and "Iteration can be reduced by 4 as I already reach the last 5 digits" (this explained the i-4 thingy in my for loop ).
No comments:
Post a Comment