Sequence with sum K and minimum sum of absolute differences between consecutive elements | Java implementation of the approach ; Function to return the minimized sum ; If k is divisible by n then the answer will be 0 ; Else the answer will be 1 ; Driver code
import java . io . * ; class GFG { static int minimum_sum ( int n , int k ) { if ( k % n == 0 ) return 0 ; return 1 ; } public static void main ( String [ ] args ) { int n = 3 , k = 56 ; System . out . println ( minimum_sum ( n , k ) ) ; } }