Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Clear category for Friendly Number by gyahun_dash
def friendly_number(number, base=1000, decimals=0, suffix='',
powers=['', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y']):
exponents = [e for e in range(len(powers)) if base**e <= abs(number)]
exponent = max(exponents) if exponents != [] else 0
divided = number / base**exponent
approx = round(divided, decimals) if decimals > 0 else int(divided)
return '{:.{}f}{}{}'.format(approx, decimals, powers[exponent], suffix)
March 28, 2014
Comments: