Generate an N | C ++ program for the above approach ; Function to construct an array with sum of each subarray divisible by K ; Traverse a loop from 1 to N ; Print i - th multiple of K ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; void construct_Array ( int N , int K ) { for ( int i = 1 ; i <= N ; i ++ ) { cout << K * i << " ▁ " ; } } int main ( ) { int N = 3 , K = 3 ; construct_Array ( N , K ) ; return 0 ; }