Write a python program to print and count all numbers from 0 to n which are divisible by 5 and having none of the digits being repeated.
def checkRepeatingDigits(numb):
checkString = str(numb)
flag = True
for i in range(len(checkString)-1):
for j in range(i+1,len(checkString)):
if checkString[i] == checkString[j]:
flag = False
break
if flag == False:
break
return(flag)
n = int(input("Enter the limit:"))
counter = 0
for i in range(n):
numb = i
if numb % 5 == 0:
if checkRepeatingDigits(numb) == True:
counter +=1
print(numb)
print("Total number of numbers divisible by 5 and having non-repeating characters =",counter)
No comments:
Post a Comment