C# program to group the sequence of number

This program will group the sequence of a number from the list with (-), for this example input 1,2,3,4  the output will be 1-4. If there is no sequence of the number then it should be printed as it is, example: 1,3,10 will provide the following output 1,3,10.

Program

Output:

Enter the number:
1,2,3,4,10,11,12,20,100
1-4,10-12,20,100

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.