Given an infinite arithmetically-progressive¹ sequence, compute the minimum length of a prefix with a product divisible by 2^8.
Sample cases & reference implementation
Here is a reference implementation that I wrote in Io.
1, 1 -> 10
2, 4 -> 8
3, 5 -> 10
2, 6 -> 5
7, 5 -> 6
4, 1 -> 9
10, 9 -> 7
256, 9 -> 1
Spec
- The input will always be provided in a way such that it won't take forever to zero the accumulator.
- ¹ An arithmetically progressive infinite list can be generated by a constant step each time starting from an initial number.
- For the infinite list input, you're are allowed to simply take the initial number and the step of the infinite list.
There are only going to be integers in this sequence.
Examples
1*2*3*4*5*6*7*8*9*10 = 3,628,800 = 14,175*256
- 2*6*10*14*18*22*26*30 = 518,918,400 = 2,027,025 * 256