text: Find K consecutive integers such that their sum is N | C # implementation to check if a number can be expressed as sum of K consecutive integer ; Function to check if a number can be expressed as the sum of k consecutive ; Finding the first term of AP ; Checking if first term is an integer ; Loop to print the K consecutive integers ; Driver Code
code: using System ; class GFG { static void checksum ( int n , int k ) { float first_term = ( float ) ( ( ( 2 * n ) / k + ( 1 - k ) ) / 2.0 ) ; if ( first_term - ( int ) ( first_term ) == 0 ) { for ( int i = ( int ) first_term ; i <= first_term + k - 1 ; i ++ ) { Console . Write ( i + " ▁ " ) ; } } else Console . Write ( " - 1" ) ; } public static void Main ( String [ ] args ) { int n = 33 , k = 6 ; checksum ( n , k ) ; } }