Difference between random number generating in main function and subroutine