Problem Statement:
You are at Level-1 of a Maths game. You are provided with 4 numbers: input1, input2, input3 and input4 and are expected to find a secret PIN.
The three numbers input1, input2 and input3 are four-digit numbers within the range >=1000 and <=9999. i.e.
input4 is a positive integer number.
Rules:
Example 1:
If input4 = 38 (an EVEN number) and if input1 = 3521, input2 = 2452, input3 = 1352, then PIN = (2+2+4+2+2) = 12.
Example 2:
If input4 = 37 (an ODD number) and if input1 = 3521, input2 = 2452, input3 = 1352, then PIN = (3+5+1+5+1+3+5) = 23.
Assuming that the 4 numbers are passed to the given function, Complete the function to find and return the PIN.
Problem Statement:
Calculate sum of non-prime index values in an array:
What is a prime number?
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 of N elements, you are expected to find the sum of the values that are present in non-prime indexes of the array. Note that the array 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.
Example 1:
If the array elements are (10, 20, 30, 40, 50, 60, 70, 80, 90, 100), then the values at the non-prime index are 10, 20, 50, 70, 90, 100 and their sum is 340. (Indices 0, 1, 4, 6, 8, 9)
Example 2:
If the array elements are (-1, -2, -3, 3, 4, -7), then the values at the non-prime index are -1, -2, 4 and their sum is 1. (Indices 0, 1, 4)
The function prototype should be as below:
int sumOfNonPrimeIndexValues(int input1[], int input2);
where input1 is the given array, and input2 is the no. of elements in the array.