Largest product in a series
The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832.
Even though this problem looks very big, it is very simple. Unlike every time I was satisfied with my first solution. So I didn't bother writing another program.
Also the program is simple.
I think it is pretty simple. If you have any doubt with the program you can visit some of these links, so that you can get some idea how the program works.
Python join strings
How to split a string into array of characters
Convert all strings in a list to int
Multiply all items in a list together
If you want to download the above program you can download it from github gist.
I haven't explained any part of the code in this post because it is based on the basics with python. Also the code has been properly commented and so I think it is not really necessary explaining the code. But if you have any doubt or didn't understand any part of the code, then please do comment in the comment box below and I will be glad to help you.
Please don't hesitate to comment if I have made any typo or if you want me to add anything in this post. Comment if you have a better and fast running code.
You can also contact me if you want to.
Thanks, Have a nice day😃.
73167176531330624919225119674426574742355349194934
96983520312774506326239578318016984801869478851843
85861560789112949495459501737958331952853208805511
12540698747158523863050715693290963295227443043557
66896648950445244523161731856403098711121722383113
62229893423380308135336276614282806444486645238749
30358907296290491560440772390713810515859307960866
70172427121883998797908792274921901699720888093776
65727333001053367881220235421809751254540594752243
52584907711670556013604839586446706324415722155397
53697817977846174064955149290862569321978468622482
83972241375657056057490261407972968652414535100474
82166370484403199890008895243450658541227588666881
16427171479924442928230863465674813919123162824586
17866458359124566529476545682848912883142607690042
24219022671055626321111109370544217506941658960408
07198403850962455444362981230987879927244284909188
84580156166097919133875499200524063689912560717606
05886116467109405077541002256983155200055935729725
71636269561882670428252483600823257530420752963450
Find the thirteen adjacent digits in the 1000-digit number that have the greatest product. What is the value of this product?96983520312774506326239578318016984801869478851843
85861560789112949495459501737958331952853208805511
12540698747158523863050715693290963295227443043557
66896648950445244523161731856403098711121722383113
62229893423380308135336276614282806444486645238749
30358907296290491560440772390713810515859307960866
70172427121883998797908792274921901699720888093776
65727333001053367881220235421809751254540594752243
52584907711670556013604839586446706324415722155397
53697817977846174064955149290862569321978468622482
83972241375657056057490261407972968652414535100474
82166370484403199890008895243450658541227588666881
16427171479924442928230863465674813919123162824586
17866458359124566529476545682848912883142607690042
24219022671055626321111109370544217506941658960408
07198403850962455444362981230987879927244284909188
84580156166097919133875499200524063689912560717606
05886116467109405077541002256983155200055935729725
71636269561882670428252483600823257530420752963450
Even though this problem looks very big, it is very simple. Unlike every time I was satisfied with my first solution. So I didn't bother writing another program.
Also the program is simple.
Program
Program which I wrote is as follows:I think it is pretty simple. If you have any doubt with the program you can visit some of these links, so that you can get some idea how the program works.
Python join strings
How to split a string into array of characters
Convert all strings in a list to int
Multiply all items in a list together
If you want to download the above program you can download it from github gist.
Output
Summary
This problem is straight forward with python. I don't know the case with other programming languages. Solving this problem with python has made it easy because of the inbuilt functions that python has.I haven't explained any part of the code in this post because it is based on the basics with python. Also the code has been properly commented and so I think it is not really necessary explaining the code. But if you have any doubt or didn't understand any part of the code, then please do comment in the comment box below and I will be glad to help you.
Please don't hesitate to comment if I have made any typo or if you want me to add anything in this post. Comment if you have a better and fast running code.
You can also contact me if you want to.
Thanks, Have a nice day😃.