05-03-2012, 09:15 PM
I got a small challenge from a Youtube user, as follows:
So, here's the solution!
Pastebin version: http://pastebin.com/M1EZ73nw
Just thought that I would share!
Quote:Write a program to print out all of the numbers between 1 and 1000 inclusive. Each number should be seperated by a space. There should only be 10 numbers printed on any given line, i.e. every 10th number should be followed by the new line character.
So, here's the solution!
Code:
for (int i = 1; i <= 1000; i++) {
System.out.print(i + " ");
if (i % 10 == 0)
System.out.println();
}
Pastebin version: http://pastebin.com/M1EZ73nw
Just thought that I would share!