We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
def decentNumber(n):
"""
n = length of number
we want the largest number => should get set all as 5 first
"""
output = ""
fives,threes = n,0
decent = False
while (fives >= 0):
if (fives % 3 == 0) and (threes % 5 == 0):
decent = True
break
else:
threes += 1
fives -= 1
#print(decent)
if decent:
output += "5"*fives
output += "3"*threes
else: output = -1
print(output)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Sherlock and The Beast
You are viewing a single comment's thread. Return to all comments →
Python3 solution