Given a number **N**. The task is to find the smallest N digit ODD number.

**Examples:**

Input:N = 1Output:1Input:N = 3Output:101

**Approach**: There can be two cases depending on the value of N.

**Case 1** : If N = 1 then answer will be 1.

**Case 2** : If N != 1 then answer will be (10^(n-1)) + 1 because the series of the smallest odd numbers will go on like: *1, 11, 101, 1001, 10001, 100001, * ….

Below is the implementation of the above approach:

## C++

`// C++ implementation of the above approach ` ` ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// Function to return smallest odd ` `// with n digits ` `int` `smallestOdd(` `int` `n) ` `{ ` ` ` `if` `(n == 1) ` ` ` `return` `1; ` ` ` ` ` `return` `pow` `(10, n - 1) + 1; ` `} ` ` ` `// Driver Code ` `int` `main() ` `{ ` ` ` `int` `n = 4; ` ` ` `cout << smallestOdd(n); ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java implementation of the approach ` `class` `Solution { ` ` ` ` ` `// Function to return smallest odd with n digits ` ` ` `static` `int` `smallestOdd(` `int` `n) ` ` ` `{ ` ` ` `if` `(n == ` `1` `) ` ` ` `return` `0` `; ` ` ` `return` `Math.pow(` `10` `, n - ` `1` `) + ` `1` `; ` ` ` `} ` ` ` ` ` `// Driver code ` ` ` `public` `static` `void` `main(String args[]) ` ` ` `{ ` ` ` `int` `n = ` `4` `; ` ` ` ` ` `System.out.println(smallestOdd(n)); ` ` ` `} ` `} ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 implementation of the approach ` ` ` `# Function to return smallest even ` `# number with n digits ` `def` `smallestOdd(n) : ` ` ` ` ` `if` `(n ` `=` `=` `1` `): ` ` ` `return` `1` ` ` `return` `pow` `(` `10` `, n ` `-` `1` `) ` `+` `1` ` ` `# Driver Code ` `n ` `=` `4` `print` `(smallestOdd(n)) ` ` ` `# This code is contributed by ihritik. ` |

*chevron_right*

*filter_none*

## C#

`// C# implementation of the approach ` `using` `System; ` `class` `Solution { ` ` ` ` ` `// Function to return smallest odd with n digits ` ` ` `static` `int` `smallestOdd(` `int` `n) ` ` ` `{ ` ` ` `if` `(n == 1) ` ` ` `return` `0; ` ` ` ` ` `return` `Math.pow(10, n - 1) + 1; ` ` ` `} ` ` ` ` ` `// Driver code ` ` ` `public` `static` `void` `Main() ` ` ` `{ ` ` ` `int` `n = 4; ` ` ` ` ` `Console.Write(smallestOdd(n)); ` ` ` `} ` `} ` |

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP implementation of the approach ` ` ` `// Function to return smallest even ` `// number with n digits ` `function` `smallestOdd(` `$n` `) ` `{ ` ` ` `if` `(` `$n` `== 1) ` ` ` `return` `1; ` ` ` `return` `pow(10, ` `$n` `- 1) + 1; ` `} ` ` ` `// Driver Code ` `$n` `= 4; ` `echo` `smallestOdd(` `$n` `); ` ` ` `// This code is contributed by ihritik ` `?> ` |

*chevron_right*

*filter_none*

**Output:**

1001

**Time Complexity:** O(1).

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- Even digits Sum and Odd digits sum divisible by 4 and 3 respectively
- Numbers of Length N having digits A and B and whose sum of digits contain only digits A and B
- Average of odd numbers till a given odd number
- Split the array into odd number of segments of odd lengths
- Primality test for the sum of digits at odd places of a number
- Smallest Even number with N digits
- Smallest number greater than Y with sum of digits equal to X
- Smallest and Largest Palindrome with N Digits
- Program to calculate the number of odd days in given number of years
- Express an odd number as sum of prime numbers
- Find sum of odd factors of a number
- PHP | check if a number is Even or Odd
- Expressing a number as sum of consecutive | Set 2 (Using odd factors)
- Program to find count of numbers having odd number of divisors in given range
- Check if a N base number is Even or Odd
- Largest Even and Odd N-digit numbers in Octal Number System
- Check if an Octal number is Even or Odd
- First number to leave an odd remainder after repetitive division by 2
- Check whether count of odd and even factors of a number are equal
- Smallest number S such that N is a factor of S factorial or S!

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.