Array Operations: Remaining Elements of the Array You are given an integer array of size N. You need to find the minimum number that should be added to each element of the array such that, after addition, the element is divisible by the rest of the elements of the array. Function Description In the provided code snippet, implement the provided divisible (...) method using the variables to print the output. You can write your code in the space below the phrase "WRITE YOUR LOGIC HERE". There will be multiple test cases running so the Input and Output should match exactly as provided. The base Output variable result is set to a default value of −404 which can be modified. Additionally, you can add or remove these output variables. Note The size of the array is greater than 1.(n>1) The value of each element is greater than 0 . (arr>0) Input Format The first line contains an integer N, denoting the size of the array A. The second line contains N integers of array A.
Output Format For each index i(2<=i<=n), output the minimum number that should be added in arr such that arr will be divisible by the remaining elements of the array. Explanation The LCM of all the given elements is 12. For i=1, LCM is 12 . The remainder will be 1 , so if we add 11 to arr [1], it will be divisible by the remaining elements. Similarly, For i=2,LCM=12. The remainder =2. Hence, the answer is 10 . For i=3,LCM=4. The remainder =3. Hence, the answer is 1 . For i=4,LCM=6. The remainder =4. Hence, the answer is 2 .
Array Operations: Remaining Elements of the Array You are given an integer array of size N. You need to find the minimum
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Array Operations: Remaining Elements of the Array You are given an integer array of size N. You need to find the minimum
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!