[URI Online Judge] – 1070 – Six Odd Numbers

Read an integer value X and print the 6 consecutive odd numbers from X, a value per line, including X if it is the case.

Input

The input will be a positive integer value.

Output

The output will be a sequence of six odd numbers.

Sample Input Sample Output
8 9
11
13
15
17
19

Solution:

#include <iostream>
int main(){
 int n;
std::cin >> n;
if (n % 2 == 0)
 n++;
 for (int i = 0; i <= 5; i++, n += 2) std::cout << n << std::endl;
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