Q:

Java Program to print all odd integers up to N and print 10 integer per line

I'm having a little trouble with my program. I already wrote my user validation and I can print all odd numbers up to what the user inputed. My problem is trying to get 10 integers on every line. Obviously, I tried the i % 10 == 0 technique and as you know odd number can't have a remainder of zero. If you could give some tips or guidance that's be fantastic!
import java.util.*;

public class Question {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        int n;
        System.out.print("Please enter a number. ");
        n = input.nextInt();

        while(n < 0 || n > 1000){
           System.out.print("Error: 0 <= N <= 1000. Reenter.");
           n = input.nextInt();
         }

        for(int i = 1; i <= n; i+=1) {
            System.out.print(" " + i);
            if(i % 10 == 0)
             System.out.print("\n");
        }
    }

}

A:

The following logic seems to work:
for (int i=1; i <= n; i+=1) {
    if (i % 2 == 1)
        System.out.print(" " + i);
    if (i % 20 == 0)
        System.out.print("\n");
}

The basic idea here is that the (i % 2 == 1) condition prints only odd numbers, and the (i % 20 == 0) adds a line break every ten numbers.  The reason we use mod 20 is that there are ten odd numbers for every 20 counting numbers.
Demo

