Skip with continue

Lab Java Beginner 10 points

Read n and print the numbers 1..n on one line, skipping those that contain the digit 7 or are divisible by 7.

Input

One integer.

Output

One line.

Example

Input

20

Output

1 2 3 4 5 6 8 9 10 11 12 13 15 16 18 19 20
Sample input available Sample output available
Editor
Java

Hints

continue skips the rest of this iteration.

Solution explanation

continue keeps the main body free of deep nesting.

Show solution
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        for (int i = 1; i <= n; i++) {
            if (i % 7 == 0 || String.valueOf(i).contains("7")) {
                continue;
            }
            if (sb.length() > 0) {
                sb.append(' ');
            }
            sb.append(i);
        }
        System.out.println(sb);
    }
}
Output
Answer
HOME LEARN COMMUNITY DASHBOARD