In this post, I'm going to explain about a question which I came across on quora.
The question asks us to calculate gcd of all of the subarrays. If you don;t know what subarray is visit here.
Suppose A = [1, 2, 3, 4, 5] then subarrays are:
[1], [2], [3], [4], [5],
[1, 2], [2, 3], [3, 4], [4, 5],
[1, 2, 3], [2, 3, 4], [3, 4, 5],
[1, 2, 3, 4], [2, 3, 4, 5]
[1, 2, 3, 4, 5].
Our objective is...