I'm trying to call the random function inside another function. For example I want to do this assert(fact(random()).
But it does not work. How can I insert a random number this way? Thanks.
In prolog there is no concept of functions like you are trying to do in your code. You should do:
random(N), assert(fact(N))
I recommend reading at least first two chapters Learn Prolog Now! to better understand search and unification.