Skip to main content
1 of 3
ElPedro
  • 6.5k
  • 2
  • 24
  • 38

Python 2, 84 bytes

i=input()[::-1];o=""
for x in"kMGT ":o+=(i,i[0:3]+x)[len(i)>3];i=i[3:]
print o[::-1]

Try it online!

  • Reverse the input
  • Step through in threes appending the next letter
  • Reverse and print

Not sure that this is the most efficient approach but it's the best I can come up with at the moment.

ElPedro
  • 6.5k
  • 2
  • 24
  • 38