Mega Code Archive

 
Categories / Perl / System Functions
 

Formula to produce random numbers between 5 and 15 inclusive

#!/usr/bin/perl $x=5 ;    $y=15;    # Formula to produce random numbers between 5 and 15 inclusive # $random = int(rand($y - $x + 1)) + $x; # $random = int(rand(15 - 5 + 1)) + 5 while(1){     print int(rand($y - $x + 1)) + $x , "\n";     sleep 1; }