Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

4. range-15% Write a function range that takes a starting index min, a step valu

ID: 3881609 • Letter: 4

Question

4. range-15% Write a function range that takes a starting index min, a step value step, and a max index max and returns a list of integers [min, min+step, min+2 step, ,min+k step] where k is the largest integer such that (min+k*step)max and (mint (k+1) *step )2max.ifmin2max and step20 OR minmax and stepšo, then the function should return an empty list This function should have type int -> int -> int -> int list Examples: > range 0 5 30 0,5,10,15, 20,25] > range 10 1 10 [1 > range 5 -1 0 5,4,3,2,1] range 1 -1 10 [1

Explanation / Answer

function main()

function lst = range(min, step, max)

lst = []
j=1
while min < max
lst(j) = min
min = min + step
j = j + 1
end

end

range(0,5,30)


end

Output:

j = 1
lst = 0
min = 5
j = 2
lst =

0 5

min = 10
j = 3
lst =

0 5 10

min = 15
j = 4
lst =

0 5 10 15

min = 20
j = 5
lst =

0 5 10 15 20

min = 25
j = 6
lst =

0 5 10 15 20 25

min = 30
j = 7
ans =

0 5 10 15 20 25

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote