text: Sum of elements in given range from Array formed by infinitely concatenating given array | C # program for the above approach ; 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: using System ; class GFG { static void rangeSum ( int [ ] arr , int N , int L , int R ) { int sum = 0 ; for ( int i = L - 1 ; i < R ; i ++ ) { sum += arr [ i % N ] ; } Console . Write ( sum ) ; } public static void Main ( string [ ] args ) { int [ ] arr = { 5 , 2 , 6 , 9 } ; int L = 10 , R = 13 ; int N = arr . Length ; rangeSum ( arr , N , L , R ) ; } }