Modify sequence of first N natural numbers to a given array by replacing pairs with their GCD | C ++ program for the above approach ; Function to check if array arr [ ] can be obtained from first N natural numbers or not ; Driver Code ; Function Call
#include <bits/stdc++.h> NEW_LINE using namespace std ; void isSequenceValid ( vector < int > & B , int N ) { for ( int i = 0 ; i < N ; i ++ ) { if ( ( i + 1 ) % B [ i ] != 0 ) { cout << " No " ; return ; } } cout << " Yes " ; } int main ( ) { int N = 4 ; vector < int > arr { 1 , 2 , 3 , 2 } ; isSequenceValid ( arr , N ) ; return 0 ; }