you are given on integer N and integer array A as the input where N denotes the length of A.write a program to find the product of every element with its next consecutive integers on the number line and return the sum of these products
Answers
Answered by
1
Code: [in Python language]
Explanation:
To create an array, the library is required. We retrieve the number of elements required, in the variable 'N'. A list is created to store the numbers that are going to be entered. The numbers are retrieved using a loop and as they're being entered, they're added to the list earlier created for the same using the method. The required array, 'A', is created. We then create a dictionary 'prod_dict' to store the product of the elements with their consecutive numbers on the number line. The final sum is printed in an appropriate statement.
Similar questions