- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

Suppose we have a number n. We have to check whether the product of odd placed digits and the even placed digits are same or not.

So, if the input is like n = 2364, then the output will be True as product of odd placed numbers are 2 * 6 = 12 and product of even placed numbers are 3 * 4 = 12 which are same.

To solve this, we will follow these steps −

- if num < 10, then
- return False

- odd_place := 1, even_place := 1
- while num > 0, do
- d := last digit of num
- odd_place := odd_place * d
- num := quotient of (num/10)
- if num is same as 0, then
- break

- d := last digit of num
- even_place := even_place * d
- num := quotient of (num/10)

- if odd_place is same as even_place, then
- return True

- return False

Let us see the following implementation to get better understanding −

def solve(num): if num < 10: return False odd_place = 1 even_place = 1 while num > 0: d = num % 10 odd_place *= d num = num//10 if num == 0: break d = num % 10 even_place *= d num = num//10 if odd_place == even_place: return True return False num = 2364 print(solve(num))

2364

True

- Related Questions & Answers
- Check whether product of digits at even places is divisible by sum of digits at odd place of a numbers in Python
- Check whether product of digits at even places of a number is divisible by K in Python
- Find the sum of digits of a number at even and odd places in C++
- Check whether sum of digits at odd places of a number is divisible by K in Python
- Primality test for the sum of digits at odd places of a number in C++
- Check if count of divisors is even or odd in Python
- How to Check if a Number is Odd or Even using Python?
- Check whether product of 'n' numbers is even or odd in Python
- PHP program to check if the total number of divisors of a number is even or odd
- Difference between sums of odd and even digits.
- Count number of ordered pairs with Even and Odd Product in C++
- Sum of individual even and odd digits in a string number using JavaScript
- Program to check if a number is Positive, Negative, Odd, Even, Zero?
- Python Program for Check if the count of divisors is even or odd
- Python Program for Difference between sums of odd and even digits

Advertisements