We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
The bounds for N are way higher here than on project Euler. Never the less it is possible even in Python to compute the whole thing in the time alotted. In my loop to consider all products I only needed to keep track of three numbers for each element in the queue: the product the sum and the largest factor in the current product. All products can then be generated recursively by condidering previous products and multiplying by a new number of value greater than or equal to what was previously the largest factor. Since 2k is always a product for k of length k i.e. 1*1*....*1*2*k=1+...+1+2+k when we have k-2 ones, the univeral bound for products is 2N.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #88: Product-sum numbers
You are viewing a single comment's thread. Return to all comments →
The bounds for N are way higher here than on project Euler. Never the less it is possible even in Python to compute the whole thing in the time alotted. In my loop to consider all products I only needed to keep track of three numbers for each element in the queue: the product the sum and the largest factor in the current product. All products can then be generated recursively by condidering previous products and multiplying by a new number of value greater than or equal to what was previously the largest factor. Since 2k is always a product for k of length k i.e. 1*1*....*1*2*k=1+...+1+2+k when we have k-2 ones, the univeral bound for products is 2N.