You can store the index for each step that is in the factorization of the elements of the array, and for the request number, the indexes of its factorization in the given range and find the maximum GCD between them.
Indexes can be implemented as lists with pairs (position in the array, main power), while the segment search is in the log.
eg. if the array is [4, 5, 8, 12, 3], we have 3 different primes (2, 3, 5) and indices:
2 -> [(0, 4), (2, 8), (3, 4)]
3 -> [(3, 3), (4, 3)]
5 -> [(1,5)]
For the query (6, 1, 3), since 6 = 2 * 3 should look like in subindexes:
2 -> [(2, 8), (3, 4)]
3 -> [(3, 3)]
Going “parallel” through these subindexes and creating a GCD product for prime numbers (minimum primary power in the number of queries and the second element of the index) will lead to the creation of all possible GCDs.