[Question]
  [
Convert a large int (e. g. 1234567890) into a string containing the usual decimal prefixes k, M, G, T, etc. for kilo, mega, giga, tera, etc. The result shall be groups of three digits, interspersed by the prefixes (e. g. `1G234M567k890`), so that it is easy to glance the order of magnitude of the number without counting the digits.
It shall work for numbers of all digit counts up to 15. Only non-negative numbers are allowed as input.
More test cases:
```
0 → 0
123 → 123
1234 → 1k234
1000 → 1k000
1000000000 → 1G000M000k000
```
  
[Answer]
# JavaScript (ES6), 64 bytes
Takes input as a string.
```
f=(n,i=0,[d,t]=n.split(/(...)$/))=>t?f(d,i+1)+['kMGT'[d&&i]]+t:d
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/f8/zVYjTyfT1kAnOkWnJNY2T6@4ICezRENfQ09PT1NFX1PT1q7EPk0jRSdT21BTO1o929c9RD06RU0tMzZWu8Qq5X9yfl5xfk6qXk5@ukaahpKhkZKmJheGoDF2URMcwqa4xM1wSphbWBrglQQDoIr/AA "JavaScript (Node.js) – Try It Online")
### How?
The regular expression `/(...)/$` matches the last three digits of the integer, or nothing at all if there are less than 3 digits remaining.
Because there's a capturing group, these digits -- if present -- are included in the output of the `.split()` method.
*Examples:*
```
'123456789'.split(/(...)$/) // --> [ '123456', '789' '' ]
'123'.split(/(...)$/))      // --> [ '', '123' ]
'12'.split(/(...)$/))       // --> [ '12' ]
''.split(/(...)$/))         // --> [ '' ]
```
### Commented
```
f = (                 // f is a recursive function taking:
  n,                  //   n = input
  i = 0,              //   i = index of next prefix
  [d, t] =            //   d = either the leading digits without the last 3 ones,
                      //       or all remaining digits if there are less than 3
    n.split(/(...)$/) //   t = last three digits (or undefined)
) =>                  //
  t ?                 // if t is defined:
    f(d, i + 1) +     //   append the result of a recursive call with d and i + 1
    ['kMGT'[d && i]]  //   append the prefix if d is defined, or an empty string otherwise
    + t               //   append the last 3 digits
  :                   // else:
    d                 //   stop recursion and return the remaining digits
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~15~~ 14 bytes
```
R3ô"kMGTP"øSR¦
```
[Try it online!](https://tio.run/##yy9OTMpM/f8/yPjwFqVsX/eQAKXDO4KDDi37/9/QyNjE1MzcwtIAzAIA "05AB1E – Try It Online")
Thanks to Kevin Cruijssen for -1 byte
```
R       reverse input
3ô      split it into groups of 3 digits
"kMGTP" push the prefixes
ø       zip the groups of numbers with them
S       split to a list of characters
R       reverse again
¦       drop the first element
        implicitly print
```
[Answer]
# [Python 2](https://docs.python.org/2/), 57 bytes
```
f=lambda s,p="":s and f(s[:-3],p[1:]+"kMGT")+s[-3:]+p[:1]
```
[Try it online!](https://tio.run/##K6gsycjPM/r/P802JzE3KSVRoVinwFZJyapYITEvRSFNozjaStc4Vqcg2tAqVlsp29c9RElTuzha1xjILYi2Moz9n5ZfpBCvkJmnUJSYl56qYWiqacXFWVCUmVcC1J6ZV1BaoqGp@V/J0EiJC0gYQ0gTKGUKo83gDHMEywKJaYnMNkDhoPHQuRh8TAEDJQA "Python 2 – Try It Online")
Takes input as a string. If the output may have a trailing space, we can avoid some workarounds and save 3 bytes. 
**54 bytes**
```
f=lambda s,p=" kMGT":s and f(s[:-3],p[1:])+s[-3:]+p[0]
```
[Try it online!](https://tio.run/##K6gsycjPM/r/P802JzE3KSVRoVinwFZJIdvXPUTJqlghMS9FIU2jONpK1zhWpyDa0CpWU7s4WtfYKla7INog9n9afpFCvEJmnkJRYl56qoahqaYVF2dBUWZeCVBbZl5BaYmGpuZ/JUMjJS4gYQwhTaCUKYw2gzPMESwLJKYlMtsAhYPGQ@di8DEFDJQA "Python 2 – Try It Online")
One potentially-useful observation is that the string format `'{:,}'.format` puts commas in the places we want to insert letters:
```
'{:,}'.format(1234567) == "1,234,567"
```
However, I haven't found a short enough way to use this.
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 17 bytes
```
↔ġ₃;"
kMGT"↔z₀cc↔
```
Input as a string, returns through output the result, with a trailing newline :)  
Explanation:
```
            More or less a translation of Jelly answer:
↔           Reverse input string
 ġ₃         Group into triples, excluding last group with length in range (0,3]
   ;        Pair those groups with:
    "
kMGT"       A string containing a newline followed by the symbols in reverse order
     ↔      Reverse the pair so the string comes before the list of digit triplets
      z₀    Zip the pair until the smallest list is depleted
        cc  Concatenate the zipped lists together, then concatenate the strings together
          ↔ Reverse the result
```
[Try it online](https://tio.run/##SypKTM6ozMlPN/r//1HblCMLHzU1WytxZfu6hygB@VWPmhqSk4GM//@VDI2MTUzNzC0sDZT@h3kGhzr6eAa7uviF@jq5BgEA)
[Answer]
# [Perl 5](https://www.perl.org/) (-p), 40 bytes
```
y/ kMG/kMGT/while s/\d\K((\d{3})+$)/ $1/
```
[Try it online!](https://tio.run/##K0gtyjH9/79SXyHb110fiEP0yzMyc1IVivVjUmK8NTRiUqqNazW1VTT1FVQM9f//NzTiMjQyBmETMGEKIc2glLmFpQESEwz@5ReUZObnFf/XLcgBAA "Perl 5 – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 14 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
**13** if input formatted as a string is acceptable for languages which *can* handle large integers (remove `Ṿ` and quote the argument)
```
ṾṚs3żFtṚʋ“kMGT
```
A full program accepting the non-negative number as a command line argument which prints the result
**[Try it online!](https://tio.run/##y0rNyan8///hzn0Pd84qNj66x60EyDjV/ahhTrave8j///8NjYxNTM3MLSwNwCwA "Jelly – Try It Online")**
### How?
```
ṾṚs3żFtṚʋ“kMGT - Main Link: integer         e.g. 12345
Ṿ              - un-evaluate the integer         ['1', '2', '3', '4', '5']
 Ṛ             - reverse                         ['5', '4', '3', '2', '1']
  s3           - split into chunks of three      [['5', '4', '3'], ['2', '1']]
         “kMGT - literal list of characters      ['k', 'M', 'G', 'T']
        ʋ      - last four links as a dyad  i.e. f([['5', '4', '3'], ['2', '1']], ['k', 'M', 'G', 'T'])
    ż          -   zip                           [[['5', '4', '3'], 'k'], [['2', '1'],'M'], ['G'], ['T']]
     F         -   flatten                       ['5', '4', '3', 'k', '2', '1','M', 'G', 'T']
      t        -   trim (from either side)       ['5', '4', '3', 'k', '2', '1']
       Ṛ       -   reverse                       ['1', '2', 'k', '3', '4', '5']
               - implicit (smashing) print       12k345
```
[Answer]
# [PHP](https://php.net/), ~~67~~ 65 bytes
```
for(;''<$d=$argn[-++$i];)$r=$d.' kMGT'[$i%3==1?$i/3:5].$r;echo$r;
```
[Try it online!](https://tio.run/##K8go@G9jXwAk0/KLNKzV1W1UUmxVEovS86J1tbVVMmOtNVWKbFVS9NQVsn3dQ9SjVTJVjW1tDe1VMvWNrUxj9VSKrFOTM/KB1H8QraAUk6dkXZpXnFqioZKpCWMVaVr/NzQy5gJiE1MIaQalzC0sESwDLktU8C@/oCQzP6/4v64bAA "PHP – Try It Online")
Loops on input digits from right to left and concatenates each digit to `$r` variable in reversed order. When we are on 4th, 7th, etc... digit, the respective prefix is concatenated to `$r` as well. Output has a trailing space.
```
for(;''<$d=$argn[-++$i];) // loop on input digits from right to left, $d is current digit and $i is incremental (1, 2, ...)
  $r=$d                   // concatenate current digit to beginning of $r
  .' kMGT'                // string of prefixes, first item is space for first digit and causes a trailing space in output
    [$i%3==1?$i/3:5]      // if $i is 1, 4, 7, etc... concatenate letter at index of $i/3 (1/3=0.33, 4/3=1.33, 7/3=2.33, etc...)
                          // PHP uses integer part of decimal indexes, so 1.33 will return the letter at index 1
                          // for any other $i, use index 5 which doesn't exist and is equal to an empty string
  .$r;                    // concatenate $r itself to the end, so everything will be in reversed order of reading (which itself is in reversed order of input)
echo$r;                   // output $r when the loop is finished
```
A schematic example for how an output is created for input of `1234`:
```
| Current Digit | Concatenation | $r    |
|---------------|---------------|-------|
| 4             | 4             | 4     |
| 3             | 3             | 34    |
| 2             | 2             | 234   |
| 1             | 1k            | 1k234 |
```
[Answer]
# [Icon](https://github.com/gtownsend/icon), ~~76~~ 71 bytes
```
procedure f(s)
k:=0
s[i:=*s-2to 2by-3:i]:="kMGT"[k+:=1]&\z
return s
end
```
[Try it online!](https://tio.run/##y0zOz/v/v6AoPzk1pbQoVSFNo1iTK9vK1oCrODrTylarWNeoJF/BKKlS19gqM9bKVinb1z1EKTpb28rWMFYtpoqrKLWktChPoZgrNS8FyZzcxMw8DU0uBQWF8qLMklSNNA0lQyNjE1MzcwtLAyVNVBlLC3N0IaBiqEKQuQA "Icon – Try It Online")
Takes input as a string.
[Answer]
# [Poetic](https://mcaweb.matc.edu/winslojr/vicom128/final/tio/), 485 bytes
```
honestly
i lived my life
i faced a boatload of brutal challenges
i desire a day of bliss-i want badly to forget a day where things backfire
i desire a day-i covet a week-and of course i want solitude around everyone
i desire a day-i crave a year-finding no faults i seem to create everyday
i desire a day-i plead,i pray-for an answer i need,i should deserve
fea-r-s,smea-r-s
really,i have a stupid aim
oh world,why was i on earth
o,i suggest venus
o,i deserve a way i go to space
by-by
```
[Try it online!](https://mcaweb.matc.edu/winslojr/vicom128/final/tio/index.html?bZFhboMwDIX/cwofoEjdOnXqcQxxSFQTV3ECyuk7h/bXNgmJGN77/OwESaSF2xCB40YO1mYHT1Z7nK1GmAQLCzoQD1OuBRnmgMyUFlLTOdKYyYQO26HhqDpG2DEVmNBxgyLgJS9U3qo9kDlKiGlRk8x3b4RfKCPMsh2Wneg@YjoSzFKzErzxKhxLdWbJUk1AG@VmI/3Dyrj1qhHm0cfkrDcky4WVixpPidYedM6EhV4ks/4lPZjQneydrbSxAJM9ulM2SiLq/zRIZdedlDcaPOGYRz3p@joM1oO5mTC8Ummpj2jLjusgAXbJ7E57sEVhjyYJLHUJg3R0XWzvBTZKVY8v7y59UbbbCIv0OfRh9zdMbZza83r7@jxfbx@Xy/ftfP542q38AA)
Poetic is an esolang I made in 2018 for a class project. It's basically brainfuck with word-lengths instead of symbols.
The point of the language is to allow for programs to be written in free-verse poetry. It was fun to write this one (though usually two consecutive ones would be written as 11-letter words; it was hard to golf this poem and make it sound interesting!).
This poem is equivalent to the following brainfuck program, which others are more than welcome to golf:
```
,[>>->,]<<<<<<<<<<[<++>-----]<+++++<<<<<<<<[<+>---]<--------<<<<<<<<[<+>-------]<--<<<<<<<<[<+>---]<-<<<<<<<-[+[<+<<<]>>>-]>[.>[.[+]]>>]
```
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 55 bytes
```
f=(n,i=0)=>n.replace(/.+(?=...)/,d=>f(d,i+1)+'kMGT'[i])
```
[Try it online!](https://tio.run/##BcE7DgIhEADQ0xhmAs4uhRXOWlrZ2RkLwseMEtiA8fr43tv//Ahd9u@xtpjmzAzVCK/IW6We9uJDgoU0XJiIcDGRtwzRiLao1ed2vauHPHHm1kHYmsFKOTmzPTnRGkOro5VEpb0gw9AsB7siuvkH "JavaScript (Node.js) – Try It Online")
[Answer]
# [Red](http://www.red-lang.org), 85 bytes
```
func[n][p: copy"kMGT"parse reverse n[any[3 skip ahead skip insert(take p)]]reverse n]
```
[Try it online!](https://tio.run/##TYq7CgIxEAD7@4plK@3U85X7AatrxC6kCJcNhsDesskJ9/UREcRqhmGUQrtTsK6LQ4sLT5adlQGmWVbM4@2B4rUQKL3oQ7aeV9tDyUnAP8mHryYupHVTfSaQrXO/3zXRxBUi4P7QH0/ny9XssPuPxhhsbw "Red – Try It Online")
Takes the input as a string.
[Answer]
# APL+WIN, 46 bytes
Prompts for integer as a string
```
∊(n/m),¨(n←3>+/¨' '=¨m←((3/⍳5)⊂¯15↑⎕))/'TGMk '
```
[Try it online! Courtesy of Dyalog Classic](https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@ob6qvz6O2CcZcjzra0/4/6ujSyNPP1dQ5tEIjDyRsp61/aIW6grrtoRW5QL6GhrH@o97NppqPupoOrTc0fdQ2EWiCpqa@eoi7b7aCOtCA9v9pXOqG6lwg0sgYRpvAGaZm5shsC0sDNC6yLriIiak6AA "APL (Dyalog Classic) – Try It Online")
[Answer]
# [Gema](http://gema.sourceforge.net/), 88 characters
```
\A=@subst{?=\@push\{p\;?\};TGMk }
*=@reverse{@subst{<d3>=\$p\$1\@pop\{p\};@reverse{$0}}}
```
Boring double reverse approach, but looping in Gema would be painfully long.
Sample run:
```
bash-5.0$ echo -n '1234567890' | gema '\A=@subst{?=\@push\{p\;?\};TGMk };*=@reverse{@subst{<d3>=\$p\$1\@pop\{p\};@reverse{$0}}}'
1G234M567k890 
```
[Try it online!](https://tio.run/##S0/NTfz/P8bR1qG4NKm4pNreNsahoLQ4I6a6IMbaPqbWOsTdN1uhlkvL1qEotSy1qDi1GqrSJsXYzjZGpSBGxRCoJb8ApKPWGq5KxaC2tvb/f0MjYxNTM3MLSwMA "Gema – Try It Online")
[Answer]
# [C (clang)](http://clang.llvm.org/), [~~65~~](https://tio.run/##ZYvBC4IwFIfv/hXjgbDpk2Yzy3bo2Klbt@gg0kqqJUsvE//2NaEg9Du8Bx@/r0qqR6mvzila3UoTabSsVy9DpU0SyRpT61ZRG4odhBVs/fEPIx3HCOR@2B/hZBfizOTgAj8lz7LWlJE@UBQ4YMpk07VvCsDkqNKlABRzmQFmf5b89CpfbwrAYlrwEcB81vAvk4Z4zKXtjCZcBoP7AA "C (clang) – Try It Online") 62 bytes
```
f(char*n,z){for(;z--;z%3||printf(L" kMGT"+z/3))putchar(*n++);}
```
[Try it online!](https://tio.run/##ZYvRCoIwFEDf/YpxIbhXJ81mluwDeqm3fkCklVRLlr5M/falUBB6Hg/nlHH5KMzVe43lrbCh4Y46/bKoXBwrt5J9X9vKNBqPwO6nwxkit5ZEddtMPYYmikgNPhgb9iwqg8S6QCMI4AmpMXsjAKlJJRsJXC5lCjz9s@ynt9lunwPP54eYAJ4tHvFl9rARe2laa5hQweA/ "C (clang) – Try It Online")
Taking a char array as input.
Saved 3 thanks to @ceilingcat 
# [C (clang)](http://clang.llvm.org/), 68 bytes
```
f(n,s){!s|n&&f(n/10,s+1)+printf(s%3?"%d":"%d%c",n%10," kMGT"[s/3]);}
```
[Try it online!](https://tio.run/##S9ZNzknMS///P00jT6dYs1qxuCZPTQ3I0Tc00CnWNtTULijKzCtJ0yhWNbZXUk1RsgISqslKOnmqQAVKCtm@7iFK0cX6xrGa1rX/uYBKFXITM/M0NBWqudI0DHQMNK0LSkuKNZSUNK2BAoZGxliETFDEFKCCpmbmFpYYqg1AAFO9AQygalAAgqLUktKiPAUDa67a/wA "C (clang) – Try It Online")
Taking an int as input
Recursive function which first call itself and outputs after.
```
f(n,s) // Idk if it's acceptable or if I have to wrap with a g(n){f(n,0);}
{
!s| // to allow 0 value calls
n&& // when n=0 exit recursion 
f(n/10,s+1)+printf(
s%3?"%d":"%d%c" // select format string
,n%10, // digit to print
" kMGT"[s/3]);} // if second format selected add character
```
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), ~~81~~ ~~73~~ ~~71~~ ~~69~~ 64 bytes
```
($a=$args)|%{$r=$a[--$i]+' kMGT'[$j+5*!$k]+$r;$j+=$k=!($i%3)}
$r
```
[Try it online!](https://tio.run/##bc/JCsIwEAbge54ilalJbAvuK4XeeurNm4iIxi3FJVUUap@9TuKGYA7D/F9mDnM8XKXONjJNS1jRkOYlh3kIc73OxN3NQWM/CQLYTj1GVRKP2QR2XqfmgJp6oEcYQlChw2HrtkRBQJcFIREnFJ/PWaPJfGqq@EqrbU2Z5oc73V5/ULefMcYEszLwZ8h2zDcyRorREkRlVBBB79SluV2DvQ/ydpSLs1zigTB7qpbZJT0jVPHuaG@xAvzlwUKePlti@B6vkKJ8AA "PowerShell – Try It Online")
Takes argument as a splatted string.
[Answer]
# [Bash](https://www.gnu.org/software/bash/), 83 bytes
```
a=('' k M G T)
s=
(($1>99))&&s=${1: -3}
echo `$0 ${1:0:-3} $[$2+1]`${s:-$1}${a[$2]}
```
[Try it online!](https://tio.run/##FcixCoMwFAXQ/X3FHR6aUIQ8XUwgXZ3c3EQwFYPg0CFjyLen9oznE9JVo9K5Bq/aFjdmTFg0JU9Ksbyt1bppkucsDt1Q6DyuL/aIfxj3DHjl/iXbzjm5jqVwDs9spRaiCDGjHYz09Qc "Bash – Try It Online") (link shows 82 bytes, but uses function recursion instead of `$0`-recursion)
Nice little recursive solution.
Bash doesn't like invalid string indexing, which both helps (gives us our exit condition for free) and hurts (we have to have separate logic for when our number has n != 0 mod 3 digits).
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), 39 bytes
```
{flip [~] <<''k M G T>>Z~.flip.comb(3)}
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYPu/Oi0ns0Ahui5WwcZGXT1bwVfBXSHEzi6qTg8koZecn5ukYaxZ@784sVIhTUMlXlMhLb9IwUBHwdDIGEyYAEkDAwMICQEQcVMzcwtLAzDrPwA "Perl 6 – Try It Online")
[Answer]
# [Python 2](https://docs.python.org/2/), ~~84~~ 74 bytes
```
i=input();o=""
for x in"kMGT ":o=(i,x+i[-3:])[len(i)>3]+o;i=i[:-3]
print o
```
[Try it online!](https://tio.run/##K6gsycjPM/qfnJ@SqmCroK6u/j/TNjOvoLREQ9M631ZJiSstv0ihQiEzTynb1z1EQckq31YjU6dCOzNa19gqVjM6JzVPI1PTzjhWO98aqDPaStc4lqugKDOvRCH/P9A4rtSK1GQNkPGaWoam/5UMjZS4gIQxhDSBUqYw2gzOMEewLJCYlshsAxQOGg@di8HHFDBQAgA "Python 2 – Try It Online")
Previous version for 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!](https://tio.run/##ZY3LDoIwEEX3/YpmNrSiCVDxUVK3rty5a7rCGiealhBM8OsrBh8Im3vPmWRmqkdz8S4LpT9ZqmgURQEVuureMK6lXKSm8AqAnH1NW4oOrof9kYL0sWI4R51IYeKW65t1DPlOmKJb10IaUtXoGur7I6E7TGxrS/Z6xGdpHiDNgHQh@ly@K//06gvrH20GuB1y8icjG@vEp4MEng "Python 2 – Try It Online")
* ~~Reverse the input~~
* Step ~~through~~ backwards in threes ~~appending~~ prepending 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.
[Answer]
# [JavaScript (V8)](https://v8.dev/), 71 bytes
Takes input as number
```
b=(a,l=10e11,x=0,c=a/l|0)=>(l-1)?(c?c+'TGMk'[x]:'')+b(a%l,l/1000,x+1):c
```
[Try it online!](https://tio.run/##fcmxCsIwFEDR3f@QJCS176nVWokdndzcxCEJRdSHESslg/8e6Sgk3vHcmxlM717X57sY6hit5kaRRugQVdCgnDYlfUDoHacCRctd6yQ77g93dgrnhjEhLTdTUlQiAKggUTQuOv/oPXUz8hduOQixnfwSJmieskUSl2mtMrzK@To76vzZ/FkwNv74BQ "JavaScript (V8) – Try It Online")
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 31 bytes
```
r`\B...
,$.'$&
T`9630,`TGMk_`,.
```
[Try it online!](https://tio.run/##K0otycxL/P@/KCHGSU9Pj0tHRU9dRY0rJMHSzNhAJyHE3Tc7PkFH7/9/QyNjE1MzcwtLAwA "Retina 0.8.2 – Try It Online") Explanation:
```
r`\B...
```
Match groups of three digits starting from the end but ensure that there is at least one more digit before the match.
```
,$.'$&
```
Prefix each match with a marker comma and the number of digits after the match (`0` for the last match, then `3`, `6` and `9` respectively).
```
T`9630,`TGMk_`,.
```
Replace the marker and following number with the appropriate suffix.
[Answer]
# [Python 2](https://docs.python.org/2/), 72 bytes
```
f=lambda n,p=' kMGT':(n>M and f(n/M,p[1:])or'')+`n%M+M`[-3:]+p[0]
M=1000
```
[Try it online!](https://tio.run/##K6gsycjPM/r/P802JzE3KSVRIU@nwFZdIdvXPUTdSiPPzlchMS9FIU0jT99XpyDa0CpWM79IXV1TOyFP1VfbNyFa19gqVrsg2iCWy9fW0MDA4H9BUWZeCVCDoZGxiamZuYWlgeZ/AA "Python 2 – Try It Online")
[Answer]
# Python3, ~~89~~ ~~83 bytes~~ 65 chars
(or 65 bytes, if you use just ASCII, but I fancy the Unicode superscript small letters)
```
f=lambda n,p='ᵏᴹᴳᵀ':len(n)<4 and n or f(n[:-3],p[1:])+p[0]+n[-3:]
```
[Try it online!](https://tio.run/##K6gsycjPM/7/P802JzE3KSVRIU@nwFb94db@h1t2Ptyy@eHWBnWrnNQ8jTxNGxOFxLwUhTyF/CKFNI28aCtd41idgmhDq1hN7YJog1jtvGhdY6vY/wVFmXklGmka6oZGxiamZuYWlgZglrqm5n8A)
Python3, 89 bytes:
```
import re;print(''.join(sum(zip(re.findall('..?.?',str(x)[::-1]),'kMGT.'),()))[::-1][1:])
```
[Try it online!](https://tio.run/##K6gsycjPM/5foWCrYGhkbGJqZm5haQBm/c/MLcgvKlEoSrUuKMrMK9FQV9fLys/M0yguzdWoyizQKErVS8vMS0nMydFQ19Oz17NX1ykuKdKo0Iy2stI1jNXUUc/2dQ/RU9fU0dDUhApGG1rFav7/DwA)
I didn't try to shorten this dramatically. See it as an incentive to beat me :) This is my first challenge in this forum; by now I understand the asker isn't supposed to post an answer right away. Next time I will wait a little longer before doing it. But since I couldn't really undo the post (deleting the post leaves it visible to too many people anyway), I saw no use in even trying to.
[Answer]
# [Zsh](https://www.zsh.org/), 53 bytes
```
a=kMGT
for z y x (${(Oas::)1})s=$x$y$z$a[i++]$s
<<<$s
```
[Try it online!](https://tio.run/##qyrO@J@moanxP9E229c9hCstv0ihSqFSoUJBQ6Vawz@x2MpK07BWs9hWpUKlUqVKJTE6U1s7VqWYy8bGRqX4vyZXmoKhgYmpgaGBhaWxgaHRfwA "Zsh – Try It Online")
`(s::)` splits the stirng, `Oa` reverses the characters. Zsh arrays and strings are 1-indexed, so `$a[0]` on the first iteration substitutes nothing.
[Answer]
# [Haskell](https://www.haskell.org/), 99 bytes
```
f n=concatMap(\(a,b)->a++b)$reverse$zip(reverse<$>chunksOf 3(reverse$show n))(["","k","M","G","T"])
```
[Try it online!](https://tio.run/##Nci9CsIwFEDh3ae4hAwJrUWtv2A7CS4Wh7qpw21IaWibhiRV8OVjBx0@OJwGXSu7LqjeDNbDCT0mF@V8UppO@VmPSkMGZvSlt8BqWK7S9WKz3e0PPNSgMzFogb5Awx4M44rPc4yiilMrX9I6ST/KsF8faS6aUbfuWkP6n9Q1wxs05@xOSEzaSTE5T27kyUP4Ag "Haskell – Try It Online")
The function `f` takes a number, converts it into a string and splits it backwards into chunks of 3 characters, e.g.
```
reverse<$>chunksOf 3(reverse$show 1234) == ["234","1"] 
```
it then zips the list of chunks with the list of magnitue identifieres `["","k","M","G","T"]`.
Then the list is reversed and with `concatMap` converted to one string.
It uses the function `chunksOf` from the package [`Data.List.Split`](https://hackage.haskell.org/package/split-0.2.3.3/docs/Data-List-Split.html)
[Answer]
# [Forth (gforth)](http://www.complang.tuwien.ac.at/forth/gforth/Docs-html/), 84 bytes
```
: f s" kMGT" bounds <# do
1000 /mod tuck if
0 # # # d. i c@ hold then loop
0 #s #> ;
```
[Try it online!](https://tio.run/##hZLNcoIwFIX3PMUZnQ52HDHaf22d7ly5c9kNkgAZIGFC1OnT2ySCYLWWLHLDPTn3y01iqXQ6SmI7HWZIMEAQBBC494AJIQTjQlLobZSBx0127DLizk1WCRD03fgCK7iGThVjoDzhukKsZFGrnXZKlSxR7cMSqcxpu4ehCFXGlFMpFm1VxUy2ifZcp3VxozBygXmNZDFmsIACoxFCShVyh7ZQ8Nfwl/BX8DOoBd775pyGt0J/gbnd9pdswxIuHMyvVuxTnrPuuV1Mh51DKVayUHu4qBT1kK2W695R21Qx5A5a1P28VvCkudF/w3Cuqu1QDCF3TCH6/Ievavg2citoZQmpdI29SkY@7MPIWbhjxysZ3OYL3JKfOHIpyy7FwV7jVQbv4j16rWvH0VE429aUGFP9XTJEyptMH85Xj0/PL90/pPNdKl/fiIvazOEH "Forth (gforth) – Try It Online")
A function that takes a number from the stack, and returns a string as (address, length) pair, which is the standard representation for a string in Forth. Produces lots of garbage under the returned string, and a few zeros on stdout.
Forth has a [dedicated set of facilities for customized number-to-string formatting](https://www.complang.tuwien.ac.at/forth/gforth/Docs-html/Formatted-numeric-output.html#Formatted-numeric-output), and this challenge seemed to be the right place to showcase it.
On the golfing perspective, I found that `do .. if .. then loop` (test and ignore the rest of the body) is shorter than `begin .. while .. repeat` (test and break simple loop) or `do .. if leave then .. loop` (test and break counted loop).
### How it works
```
: f ( n -- addr len )
  s" kMGT"            \ Create a local string "kMGT"; gives its address and length
  bounds              \ Convert (addr, len) to (addr+8*len, addr)
  <#                  \ Initialize the buffer for number-to-string conversion
  do                  \ Loop; i = addr .. addr+8*len; stack=(n)
    1000 /mod         \   Calculate n%1000 and n/1000
    tuck if           \   Stack=(n/1000 n%1000); if n/1000 is nonzero...
      0 # # # d.      \     emit three digits from n%1000 and discard it
      i c@ hold       \     emit the next char of "kMGT"
    then              \   End if
  loop                \ End loop
  0 #s                \ Emit all the remaining digits
  #>                  \ Finish conversion; push addr/len of the result string
;                     \ End function
```
]