Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Memo solution in Clear category for Friendly Number by popomin
def friendly_number(num,decimals=0,base=1000,powers=['', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'],suffix=""):
for i,po in enumerate(powers):
if abs(num)/(base**i) < base or i == len(powers)-1:
result = num/(base**i)
result = round(result,decimals) if decimals else int(result)
return "{:.{}f}".format(result,decimals) + po + suffix
Dec. 7, 2017
Comments: