Company: Wipro_14nov
Difficulty: medium
Calculate sum of prime index values in an array Problem Description A prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself. In other words, a prime number is a whole number greater than 1, whose only two whole-number factors are 1 and itself. The first few prime numbers are 2, 3, 5, 7, 11, 13, 17, 19, 23, and 29. Given an array with 'N' elements, you are expected to find the sum of the values that are present in prime indexes of the array. Note that the array index starts with 0 i.e. the position (index) of the first array element is 0, the position of the next array element is 1, and so on. The function prototype should be as below - int sumOfPrimeIndexValues(int[] input1, int input2) where input1 is the given array, and input2 is the no. of elements in the array. Examples Example 1: Input: input1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100], input2 = 10 Output: 210 Explanation: The array elements are {10, 20, 30, 40, 50, 60