I dealt with the factorial module as follows:
-module(factorial). -export([factorial/1]). factorial(0) -> 1; factorial(Val)-> Val * factorial(Val-1).
If I run:
1> c(factorial). {ok,factorial} 2> factorial:factorial(100).
I get: 933262154439441526816992388562667004907159682643816214685929638952175999932299156089414639761565182862536979208272237582511852109168640000000000000000000000000000
How does Erlang hold such large numbers so easily? On erlang.org, when he talks about types of numbers, he simply claims that they contain either integers or float. Should it be some kind of dynamic integer that adjusts the byte size if necessary?
I think this is very cool, I just donβt know how to do it.
source share