Minimum element whose n | CPP program to find minimum element whose n - th power is greater than product of an array of size n ; function to find the minimum element ; loop to traverse and store the sum of log ; calculates the elements according to formula . ; returns the minimal element ; Driver program to test above function ; initialised array ; computes the size of array ; prints out the minimal element
#include <bits/stdc++.h> NEW_LINE using namespace std ; int findMin ( int a [ ] , int n ) { double sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) int x = exp ( sum / n ) ; return x + 1 ; } int main ( ) { int a [ ] = { 3 , 2 , 1 , 4 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << findMin ( a , n ) ; }