Find the sum of number of series after dividing the element of array from previous element.
Input : 3 7 9 10 12 18 Explanation: 3 + 7/3 + 9/7 + 10/9 + 12/10 + 18/12 = 9 (taking only integer part) Output : 9 Input : 1 12 24 30 60 Output : 18
Approach: We take elements in an array and divide the element from previous element. We do this process for all the elements of an array except very first element. Add the result after division and very first element.
Note: If any element is zero in an array then it fails to do the task and return minus one.
- Dividing an array into two halves of same sum
- Maximum sum of the array after dividing it into three segments
- Replace every array element by sum of previous and next
- Replace every array element by multiplication of previous and next
- Generate an array having Bitwise AND of the previous and the next element
- Elements greater than the previous and next element in an Array
- Rearrange an array such that every odd indexed element is greater than it previous
- Largest number dividing maximum number of elements in the array
- Smallest number dividing minimum number of elements in the Array
- Smallest number dividing minimum number of elements in the array | Set 2
- Range Query on array whose each element is XOR of index value and previous element
- Replace every array element by Bitwise Xor of previous and next element
- Replace every element of the array by its previous element
- Print all distinct integers that can be formed by K numbers from a given array of N numbers
- Bitwise AND of the sum of prime numbers and the sum of composite numbers in an array
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : nitin mittal