Tuesday, 19 Oct 2021

# Mean of fourth powers of first N natural numbers

Mean of fourth powers of first N natural numbersGiven a positive integer N, the task is to find the average of the fourth powers of the first N natural numbers.Examples:Input: N = 3Output: 32.6667Explanation:Sum of the fourth powers of the first N natural numbers = 14 + 24 + 34 = 1 + 16 + 81 = 98.Therefore, average = 98 / 3 = 32.6667.Input: N = 5Output: 12Naive Approach: The simplest approach to solve the given problem is to find the sum of the fourth powers of first N natural numbers and print its value when divided by N.Below is the implementation of the above approach:C++#include using namespace std;double findAverage(int N){            double S = 0;        for (int i = 1; i   =>  Below is the implementation of the above approach:C++#include using namespace std;double findAverage(int N){            double avg = ((6 * N * N * N * N)                  + (15 * N * N * N)                  + (10 * N * N) – 1)                 / 30.0;        return avg;}int main(){    int N = 3;    cout