I need to write numbers from 0-100 on the console, like this:
0,1,2
1,2,3
2,3,4
3,4,5
etc.
I really can't seem to figure this out. Any pointers would be nice!
I need to write numbers from 0-100 on the console, like this:
0,1,2
1,2,3
2,3,4
3,4,5
etc.
I really can't seem to figure this out. Any pointers would be nice!
It's quite easy actually, something like:
for(int i = 0; i < 100; i++) {
Console.WriteLine(string.Format("{0},{1},{2}", i, i+1, i+2));
}
It will goes from 0 to 101 because it always prints 3 numbers so the last iteration would be 99,100 otherwise. If you want it that way just edit i < 100
with i < 99
.
A LINQ way of achieving it:
Enumerable.Range(2, 99).ToList()
.ForEach(x => Console.WriteLine($"{x - 2},{x - 1},{x}"));