xdmp:random( [$max as xs:unsignedLong] ) as xs:unsignedLong
Returns a random unsigned integer between 0 and a number up to 64 bits long.
xdmp:random(100) => 47