Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Friendly Number by saklar13
def friendly_number(number, base=1000, decimals=0, suffix='',
powers=['', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y']):
x = 0
while abs(number) >= base ** (x+1) and x + 1 < len(powers): x += 1
number /= base ** x
number = round(number, decimals) if decimals else int(number)
return '{number:.{decimals}f}{0}{suffix}'.format(powers[x], **locals())
Jan. 27, 2015