Sum of fifth powers of the first n natural numbers | CPP 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
#include <bits/stdc++.h> NEW_LINE using namespace std ; long long int 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 ; } int main ( ) { int n = 5 ; cout << fifthPowerSum ( n ) << endl ; return 0 ; }