1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
-module(kuraidori).
-export([put/1]).

put([S]) -> loop(list_to_integer(atom_to_list(S))," KMGTPEZY").

loop(S,[H|[]]) -> pr(S,H);
loop(S,[H|_]) when S < 1000 ->
        if
        is_integer(S) -> pri(S,H);
        true -> pr(S,H)
        end;
loop(S,[_|L]) -> loop(S / 1000, L).

pr(S,K) -> io:format("~.1f~s~n",[S,[K]]).
pri(S,K) -> io:format("~.10B~s~n",[S,[K]]).