Sunday, May 1, 2016

URI Online Judge Solution 1067 || Odd Numbers


URI Online Judge | 1067

Odd Numbers

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Read an integer value (1 <= <= 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 if is the case.
Input SampleOutput Sample
81
3
5
7



URI Online Judge Solution 1067


import java.io.IOException;
import java.util.Scanner;
public class Main {

    public static void main(String[] args) throws IOException {
        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");
        }
    }

}



No comments:
Write comments

To know more about the problem, give us your valuable commment. We'll try to help you. Thanks

All rights reserved ©2016 -URI ONLINE JUDGE SOLUTION | Developed by Maniruzzaman Akash

© 2016 URI ONLINE JUDGE SOLUTION. Developed by Maniruzzaman Akash | Distributed By Gooyaabi Templates
Powered by Blogger.