Sum of each element raised to ( prime | C ++ implementation of the approach ; Function to return the required sum ; Driver code
#include <iostream> NEW_LINE #include <vector> NEW_LINE using namespace std ; int getSum ( vector < int > arr , int p ) { return arr . size ( ) ; } int main ( ) { vector < int > arr = { 5 , 6 , 8 } ; int p = 7 ; cout << getSum ( arr , p ) << endl ; return 0 ; }