Problem Statement:
We need to find out whether a number is expensive or not. The condition to be an expensive number is that the number of digits of prime factorization of the number is greater than the total number of digits in the number itself.
Code to find Expensive Number in Python:
def prime_fact(n): result = [] # while n doesn’t fully dissolve to 1 while n!=1: # keep finding a lowest divisible number for i in range(2,n+1): if n%i==0: result.append(i) n = n//i # stopping once found so we don’t get any greater numbers break return result input_num = int(input("Enter an INTEGER: ")) prime_factors = prime_fact(input_num) if len(str(input_num)) == len(prime_factors): print('its an expensive number') else: if len(prime_factors) > len(str(input_num)): print('cheap number') else: print('None')
Output:

Also Read:
- Hyphenate Letters in Python
- Earthquake in Python | Easy Calculation
- Striped Rectangle in Python
- Perpendicular Words in Python
- Composite Number in Python
- Greatest Among Four Numbers in Python
- Reverse the sentence in Python
- Denominations in Python
- Min and max values in an array in JavaScript
- Keyboard events in JavaScript
- Reaching Ground Floor in Python
- Number of Moves in Python
- Starks Adventure in Python
- Neutralization in Python | Assignment Expert
- Free shipping in Python
- Raj has ordered two electronic items Python | Assignment Expert
- First Place in Python
- Triples with Properties in Python
- Nested list Indexing Python
- Team Points in Python
- Two words combination in Python
- ID Card in Python
- Cipher with a key in Python | Assignment Expert
- Multiple of 5 in Python
- Sandglass Star in Python
- Multiple of 3 in Python | Assignment Expert
- Ticket selling in Cricket Stadium using Python | Assignment Expert
- Sum of List Elements in Python
- All possible subsets in Python
- Names and Nicknames in Python