[URI Online Judge] – 1075 – Remaining 2

Read an integer N. Print all numbers between 1 and 10000, which divided by N will give the rest = 2.

Input

The input is an integer N (N < 1000)

Output

Print all numbers between 1 and 10000, which divided by n will give the rest = 2, one per line.

Sample Input Sample Output
13 2
15
28
41

Solution:

#include <iostream>
#include <cstdio>
int main(){
 int n;
 std::cin >> n;
 for (int i = 1; i <= 10000; i++){
 if (i % n == 2)
 printf("%d\n", i);
 }
 return 0;
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s