open System open System.Text let separateStr (arg:string) = let rec splitStr (acc:StringBuilder) (argStr:StringBuilder) = match argStr.Length with | 0 -> "" | 1 | 2 | 3 -> argStr.ToString() + acc.ToString() | _ -> acc.Insert(0, argStr.Chars (argStr.Length-1) ) acc.Insert(0, argStr.Chars (argStr.Length-2) ) acc.Insert(0, argStr.Chars (argStr.Length-3) ) acc.Insert(0, ',' ) argStr.Length <- argStr.Length-3 splitStr acc argStr splitStr (new StringBuilder()) (new StringBuilder(arg)) Console.ReadLine() |> separateStr |> printfn "%s"