Note: The original example displays a duplicate '21' where there should be a '22'. For the given test case of '24', the code should print the following result:
20 21 22 23 24
19 6 7 8 9
18 5 0 1 10
17 4 3 2 11
16 15 14 13 12
A unit test project has been included to test various different conditions.