text: Program to find value of 1 ^ k + 2 ^ k + 3 ^ k + ... + n ^ k | Java Program to find the value 1 ^ K + 2 ^ K + 3 ^ K + . . + N ^ K ; Function to find value of 1 ^ K + 2 ^ K + 3 ^ K + . . + N ^ K ; Initialise sum to 0 ; Find the value of pow ( i , 4 ) and then add it to the sum ; Return the sum ; Drivers Code ; Function call to find the sum
code: class GFG { static int findSum ( int N , int k ) { int sum = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { sum += ( int ) Math . pow ( i , k ) ; } return sum ; } public static void main ( String [ ] args ) { int N = 8 , k = 4 ; System . out . println ( findSum ( N , k ) ) ; } }