logo CodeStepByStep logo


Related Links:

Write a console program with a main function that prompts the user to type two integers and prints the sequence of numbers between the two arguments, separated by commas and spaces. Print an increasing sequence if the first argument is smaller than the second otherwise, print a decreasing sequence. If the two numbers are the same, that number should be printed by itself. Here is an example dialogue:

Start? 2
End? 8
2, 3, 4, 5, 6, 7, 8

Your program should also be able to count downward if the end is less than the start. For example:

Start? 18
End? 11
18, 17, 16, 15, 14, 13, 12, 11 

If the start and end are the same, simply print that number a single time.

Start? 42
End? 42
Type your Kotlin solution code here:

This is a function exercise. Write a Kotlin function as described. Do not write a complete program; just the function(s) above.

You must log in before you can solve this problem.

Log In

Need help?

If you do not understand how to solve an exercise or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect tests, etc.), please

Is there a problem? Contact a site administrator.

©, all rights reserved.