Algorithm


Problem Name: beecrowd | 1067
Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/1067

Odd Numbers

Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

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 all odd values between 1 and X, including X if is the case.

Input Sample Output Sample

8

1
3
5
7

 

Code Examples

#2 Code Example with C++ Programming

Code - C++ Programming


#include <cstdio>

int main()
{
    int n;

    scanf("%i", &n);

    for (int i = 0; i  < = n; ++i)
    {
        if(i % 2 == 1)
        printf("%in", i);
    }

    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
8

Output

x
+
cmd
1 3 5 7

#3 Code Example with Java Programming

Code - Java Programming


import java.util.Scanner;
public class Main {
 
    public static void main(String[] args){
        int X;
        Scanner input =new Scanner(System.in);
        X = input.nextInt();
        System.out.print(1+"n");
        for (int i = 1; i  <  X-1; i+=2) {
           int oddNumber = i + 2;
            System.out.print(oddNumber+"n");
        }
    }
 
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
8

Output

x
+
cmd
1 3 5 7

#4 Code Example with Python Programming

Code - Python Programming


numero = int(raw_input())

i = 1

while(i <= numero):
 if(i%2 != 0):
  print i
 
 i = i + 1
Copy The Code & Try With Live Editor

Input

x
+
cmd
8

Output

x
+
cmd
1 3 5 7
Advertisements

Demonstration


Previous
#1066 Beecrowd Online Judge Solution 1066 Even, Odd, Positive and Negative - Solution in C, C++, Java, Python and C#
Next
#1068 Beecrowd Online Judge Solution 1068 Parenthesis Balance I - Solution in C, C++, Java, Python and C#