Sum of fifth powers of the first n natural numbers | Java Program to find the sum of fifth power of first n natural numbers ; calculate the sum of fifth power of first n natural numbers ; Driven Program
import java . io . * ; class GFG { static long fifthPowerSum ( int n ) { return ( ( 2 * n * n * n * n * n * n ) + ( 6 * n * n * n * n * n ) + ( 5 * n * n * n * n ) - ( n * n ) ) / 12 ; } public static void main ( String args [ ] ) { int n = 5 ; System . out . println ( fifthPowerSum ( n ) ) ; } }