[URI Online Judge] – 1067 – Odd Numbers

Read an integer value X (1 <= X <= 1000).  Then print the odd numbers from 1 to X, each one in a line, including X if is the case.

Input

The input will be an integer value.

Output

Print al odd values between 1 and X, including X if is the case.

Sample Input Sample Output
8 1
3
5
7

Solution:

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