Formula to produce random numbers between 5 and 15 inclusive : rand « System Functions « Perl






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;
}

   
    
    
    
    
    
  








Related examples in the same category

1.Using foreach loop to create a list of random number
2.Random integers produced by 1 + int( rand( 6 ) )
3.Random numbers produced by rand( 100 )
4.Random numbers produced by rand()
5.Generate random numbers
6.Let system determine seed
7.Combine rand function and letter range to generate random letter
8.Seed rand with the time or the pid of this process
9.A program that generates random integers between 1 and 10.