Skip Multiples

Lab C Beginner 10 points

Read n and k. Print 1..n on one line, skipping multiples of k using continue.

Input

Two integers.

Output

One line.

Example

Input

10 3

Output

1 2 4 5 7 8 10
Sample input available Sample output available
Editor
C

Hints

continue jumps to the next iteration.

Solution explanation

A first flag avoids a leading space.

Show solution
#include <stdio.h>

int main() {
    int n, k, first = 1;
    scanf("%d %d", &n, &k);
    for (int i = 1; i <= n; i++) {
        if (i % k == 0) continue;
        if (!first) printf(" ");
        printf("%d", i);
        first = 0;
    }
    printf("\n");
    return 0;
}
Output
Answer
HOME LEARN COMMUNITY DASHBOARD