-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreversedSequence.cs
More file actions
46 lines (37 loc) · 960 Bytes
/
Copy pathreversedSequence.cs
File metadata and controls
46 lines (37 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace reversedSequence
{
class Program
{
static void Main(string[] args)
{
//number n returns the reversed sequence from n to 1
//example: 5 => [5,4,3,2,1]
int[] arr = Kata.ReverseSeq(5);
foreach (var item in arr)
{
Console.WriteLine(item);
}
}
public static class Kata
{
public static int[] ReverseSeq(int n)
{
int minus = n;
List<int> intList = new List<int>();
do
{
intList.Add(minus);
minus--;
} while (minus >= 1);
int[] arr;
arr = intList.ToArray();
return arr;
}
}
}
}