Find if a number is divisible by every number in a list | Java program which check is a number divided with every element in list or not ; Function which check is a number divided with every element in list or not ; driver program
class GFG { static boolean findNoIsDivisibleOrNot ( int a [ ] , int n ) { for ( int i = 0 ; i < a . length ; i ++ ) { if ( a [ i ] % n != 0 ) return false ; } return true ; } public static void main ( String [ ] args ) { int a [ ] = { 14 , 12 , 4 , 18 } ; int n = 2 ; if ( findNoIsDivisibleOrNot ( a , n ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }