Check for each divisor , if it is not divisible by any perfect square , simply return it as the answer .
for ( let d = 0 ; d < l . length ; d ++ ) { let divi = 0 ; for ( let j = 0 ; j < vec . length && vec [ j ] <= l [ d ] ; j ++ ) { if ( l [ d ] % vec [ j ] == 0 ) { divi = 1 ; break ; } } if ( divi == 0 ) return l [ d ] ; } return 0 ; }