Generate an N | Java program to implement 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
import java . io . * ; import java . util . * ; class GFG { static void construct_Array ( int N , int K ) { for ( int i = 1 ; i <= N ; i ++ ) { System . out . print ( K * i + " ▁ " ) ; } } public static void main ( String [ ] args ) { int N = 3 , K = 3 ; construct_Array ( N , K ) ; } }