Iterating through all the prime numbers and check if any of the prime numbers is a factor of the given input array
for ( int i = 0 ; i < allPrimes . size ( ) ; i ++ ) { for ( int j = 0 ; j < arr . size ( ) ; j ++ ) { if ( arr . get ( j ) % allPrimes . get ( i ) == 0 ) { list1 . add ( allPrimes . get ( i ) ) ; break ; } } } return list1 ; }