Check if LCM of array elements is divisible by a prime number or not | C ++ program to find LCM of array of number is divisible by a prime number k or not ; Function to check any number of array is divisible by k or not ; If any array element is divisible by k , then LCM of whole array should also be divisible . ; Driver Code
#include <iostream> NEW_LINE using namespace std ; bool func ( int a [ ] , int k , int n ) { for ( int i = 0 ; i < n ; i ++ ) if ( a [ i ] % k == 0 ) return true ; return false ; } int main ( ) { int a [ ] = { 14 , 27 , 38 , 76 , 84 } ; int k = 19 ; bool res = func ( a , k , 5 ) ; if ( res ) cout << " true " ; else cout << " false " ; return 0 ; }