fork download
  1. let table = "0123456789abcdefghijklmnopqrstuvwxyz"
  2.  
  3. let tobigint (str:string) radix =
  4. let mutable bi = bigint(0)
  5. for c in str.ToCharArray() do
  6. bi <- bi * radix + (c|>System.Char.ToLower|>table.IndexOf|>bigint)
  7. bi
  8.  
  9. let tostring x radix =
  10. let mutable str = ""
  11. let mutable i = x
  12. while i <> bigint(0) do
  13. str <- (table.Chars((i % radix)|>int)).ToString() + str
  14. i <- i / radix
  15. str
  16.  
  17. [<EntryPoint>]
  18. let main argv =
  19. let args = "16 deadbabe".Split [|' '|]
  20. let bi = tobigint args.[1] (args.[0]|>int|>bigint)
  21.  
  22. for i in [2..36] do
  23. printfn "%d#%s" i (tostring bi (i|>bigint))
  24.  
  25. 0 // return an integer exit code
Success #stdin #stdout 0.08s 21144KB
stdin
Standard input is empty
stdout
2#11011110101011011011101010111110
3#100122100210210001200
4#3132223123222332
5#30122344134421
6#1414413520330
7#161402600604
8#33653335276
9#10570723050
10#3735927486
11#1647919685
12#8831a30a6
13#476cc28a5
14#276253874
15#16ceb1726
16#deadbabe
17#91d36cc6
18#61f27270
19#437f24b8
20#2i79aie6
21#21bff6ii
22#1akk149g
23#125a42hj
24#jd49956
25#f7do8ob
26#c2b8boi
27#9h9ll1i
28#7l225hi
29#6842o9l
30#53m7kg6
31#46f9hir
32#3farelu
33#2tf7mor
34#2e7m366
35#214kbpb
36#1ps9w3i