Function that returns the maximum length subsequence such that adjacent elements have a common factor .
static int maxLengthSubsequence ( Integer arr [ ] , int n ) { Integer dp [ ] = new Integer [ N ] ; Map < Integer , Integer > pos = new HashMap < Integer , Integer > ( ) ;