Your code as posted does not return what you have shown. As posted, the code returns 1.
As your “Expected output” looks like an array, you need to set up an array to fill and then return it at the end.
You have also made a mistake by putting the return inside the while loop. You also do not need so many variables, e.g.
Start with something like this:
result =  # this creates an array to store the final result in
# -- your loop to fill the result array
return result # this returns the array of values
Now complete “your loop” to fill the
result array with the values you want.
It looks like you need to put the numbers less than
variable1 into the result array, so the while loop should be:
j = 0 # start value for loop is 0
while j < variable1 do # repeat loop until j == variable1
# put current value of j into result
j += 1 # make sure we increment j each loop
and the instruction to add a value to the right side of an array is
So putting it all together gives:
result = 
j = 0
while j < variable1 do
j += 1