Given an array nums of positive integers, you need to find how many different GCD values can be formed by all possible non-empty subsequences.
What is GCD? The Greatest Common Divisor (GCD) of a sequence is the largest positive integer that divides all numbers in the sequence evenly. For example, GCD([4, 6, 16]) = 2 because 2 is the largest number that divides 4, 6, and 16.
What is a subsequence? A subsequence is formed by removing some (possibly zero) elements from the original array while maintaining the relative order. For example, [2, 5, 10] is a subsequence of [1, 2, 1, 2, 4, 1, 5, 10].
Your task: Count how many distinct GCD values are possible among all non-empty subsequences of the given array.
Input & Output
Constraints
- 1 β€ nums.length β€ 1000
- 1 β€ nums[i] β€ 2 Γ 105
- All elements in nums are positive integers