**Place value** can be defined as the value represented by a digit in a number on the basis of its position in the number. Here is the illustration of place value with an example:

Let’s take another example to illustrate place value for **N = 45876**

**Problem:**

Given a positive integer **N** and a digit **D**. The task is to find out the place value of a digit **D** in the given number** N**. If multiple occurrences of digit occurs then find the minimum place value.

**Example:**

Input:N = 3928, D = 3

Output:3000

Explaination:

Place value of 3 in this number is 3*1000 = 3000

Input:N = 67849, D = 6

Output:60000

**Solution Approach:**

- Find the position of the digit from the right side of the input number. In order to find the position take the mod of that number by 10 and check for the number and divide the number by 10.
- When the position of the digit is found then just multiply digit with the 10
^{ position}.

Here is the implementation of the above approach:

## C++

`// C++ implementation to find ` `// place value of a number ` `#include<bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// Function to find place value ` `int` `placeValue(` `int` `N, ` `int` `num) ` `{ ` ` ` `int` `total = 1, value = 0, rem = 0; ` ` ` `while` `(` `true` `) ` ` ` `{ ` ` ` `rem = N % 10; ` ` ` `N = N / 10; ` ` ` ` ` `if` `(rem == num) ` ` ` `{ ` ` ` `value = total * rem; ` ` ` `break` `; ` ` ` `} ` ` ` `total = total * 10; ` ` ` `} ` ` ` `return` `value; ` `} ` ` ` `// Driver Code ` `int` `main() ` `{ ` ` ` ` ` `// Digit, which we want ` ` ` `// to find place value. ` ` ` `int` `D = 5; ` ` ` ` ` `// Number from where we ` ` ` `// want to find place value. ` ` ` `int` `N = 85932; ` ` ` ` ` `cout << (placeValue(N, D)); ` `} ` ` ` `// This code is contributed by Ritik Bansal ` |

*chevron_right*

*filter_none*

## Java

`// Java implementation to find ` `// place value of a number ` ` ` `import` `java.util.*; ` `import` `java.io.*; ` `import` `java.lang.*; ` ` ` `class` `GFG { ` ` ` ` ` `// function to find place value ` ` ` `static` `int` `placeValue(` `int` `N, ` `int` `num) ` ` ` `{ ` ` ` `int` `total = ` `1` `, value = ` `0` `, rem = ` `0` `; ` ` ` `while` `(` `true` `) { ` ` ` `rem = N % ` `10` `; ` ` ` `N = N / ` `10` `; ` ` ` ` ` `if` `(rem == num) { ` ` ` `value = total * rem; ` ` ` `break` `; ` ` ` `} ` ` ` ` ` `total = total * ` `10` `; ` ` ` `} ` ` ` `return` `value; ` ` ` `} ` ` ` ` ` `// Driver Code ` ` ` `public` `static` `void` `main(String[] args) ` ` ` `{ ` ` ` ` ` `// Digit, which we want ` ` ` `// to find place value. ` ` ` `int` `D = ` `5` `; ` ` ` ` ` `// Number from where we ` ` ` `// want to find place value. ` ` ` `int` `N = ` `85932` `; ` ` ` ` ` `System.out.println(placeValue(N, D)); ` ` ` `} ` `} ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 implementation to find ` `# place value of a number ` ` ` `# Function to find place value ` `def` `placeValue(N, num): ` ` ` ` ` `total ` `=` `1` ` ` `value ` `=` `0` ` ` `rem ` `=` `0` ` ` ` ` `while` `(` `True` `): ` ` ` `rem ` `=` `N ` `%` `10` ` ` `N ` `=` `N ` `/` `/` `10` ` ` ` ` `if` `(rem ` `=` `=` `num): ` ` ` `value ` `=` `total ` `*` `rem ` ` ` `break` ` ` `total ` `=` `total ` `*` `10` ` ` ` ` `return` `value ` ` ` `# Driver Code ` ` ` `# Digit, which we want ` `# to find place value. ` `D ` `=` `5` ` ` `# Number from where we ` `# want to find place value. ` `N ` `=` `85932` ` ` `print` `(placeValue(N, D)) ` ` ` `# This code is contributed by divyamohan123 ` |

*chevron_right*

*filter_none*

## C#

`// C# implementation to find ` `// place value of a number ` `using` `System; ` `class` `GFG{ ` ` ` `// function to find place value ` `static` `int` `placeValue(` `int` `N, ` `int` `num) ` `{ ` ` ` `int` `total = 1, value = 0, rem = 0; ` ` ` `while` `(` `true` `) ` ` ` `{ ` ` ` `rem = N % 10; ` ` ` `N = N / 10; ` ` ` ` ` `if` `(rem == num) ` ` ` `{ ` ` ` `value = total * rem; ` ` ` `break` `; ` ` ` `} ` ` ` ` ` `total = total * 10; ` ` ` `} ` ` ` `return` `value; ` `} ` ` ` `// Driver Code ` `public` `static` `void` `Main() ` `{ ` ` ` ` ` `// Digit, which we want ` ` ` `// to find place value. ` ` ` `int` `D = 5; ` ` ` ` ` `// Number from where we ` ` ` `// want to find place value. ` ` ` `int` `N = 85932; ` ` ` ` ` `Console.Write(placeValue(N, D)); ` `} ` `} ` ` ` `// This code is contributed by Code_Mech ` |

*chevron_right*

*filter_none*

**Output:**

5000

**Time Complexity: ** O(log N)

**Auxiliary space: ** 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:

- Count of N-digit numbers having digit XOR as single digit
- Find the unit place digit of sum of N factorials
- Generate a number such that the frequency of each digit is digit times the frequency in given number
- Largest number less than N with digit sum greater than the digit sum of N
- Count of Numbers in Range where first digit is equal to last digit of the number
- Find the remainder when First digit of a number is divided by its Last digit
- Last digit of a number raised to last digit of N factorial
- Min steps to convert N-digit prime number into another by replacing a digit in each step
- Find total no of collisions taking place between the balls in which initial direction of each ball is given
- Count ways to place all the characters of two given strings alternately
- Total number of ways to place X and Y at n places such that no two X are together
- Check whether product of digits at even places is divisible by sum of digits at odd place of a number
- Number of ways to place two queens on a N*N chess-board
- Count 'd' digit positive integers with 0 as a digit
- Check if frequency of each digit is less than the digit
- Count n digit numbers not having a particular digit
- Count numbers in a range with digit sum divisible by K having first and last digit different
- Count of pairs (A, B) in range 1 to N such that last digit of A is equal to the first digit of B
- Count numbers with difference between number and its digit sum greater than specific value
- Largest value of x such that ax
^{x}is N-digit number of base b

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.