text: Sum of elements in given range from Array formed by infinitely concatenating given array | Function to find the sum of elements in a given range of an infinite array ; Stores the sum of array elements from L to R ; Traverse from L to R ; Print the resultant sum ; Driver Code
code: function rangeSum ( arr , N , L , R ) { let sum = 0 ; for ( let i = L - 1 ; i < R ; i ++ ) { sum += arr [ i % N ] ; } document . write ( sum ) ; } let arr = [ 5 , 2 , 6 , 9 ] ; let L = 10 , R = 13 ; let N = arr . length rangeSum ( arr , N , L , R ) ;