Computer Science, asked by tanishapaul1340, 3 months ago

write a program to input a number and find maximum Prime digit present in it.
(using scanner class )

If you spam i will report your account as well as your answer .❌​


Anonymous: Name the programming language.
tanishapaul1340: you have do it using while loop
Anonymous: Java ?
tanishapaul1340: yes Java
Anonymous: Sorry I know python.
tanishapaul1340: ok no problem

Answers

Answered by ridhimaray853
1

Answer:

# Function to print maximum number

def printMaximum(inum):

# Hashed array to store count of digits

count = [0 for x in range(10)]

# Connverting given number to string

string = str(num)

# Updating the count array

for i in range(len(string)):

count[int(string[i])] = count[int(string[i])] + 1

# Result stores final number

result = 0

multiplier = 1

# traversing the count array

# to calculate the maximum number

for i in range(10):

while count[i] > 0:

result = result + ( i * multiplier )

count[i] = count[i] - 1

multiplier = multiplier * 10

# return the result

return result

Similar questions