[ create a new paste ] login | about

Link: http://codepad.org/vhOtxIgG    [ raw code | output | fork ]

proch - Perl, pasted on May 4:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Create a variable to store how many random were generated at the end.
$howmany = 0;

while ($total < 100) {
   $random = int(rand(13));
   $howmany = $howmany + 1;
   $total = $total + $random;
   print " This time the special number is $random.";
   if ($random > 0 and $random % 3 == 0) {
     print " Lucky you!!!";
   }
   print "\n";
   
}
print " Finished: I choosed $howmany random numbers, the total is $total.\n";


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 This time the special number is 3. Lucky you!!!
 This time the special number is 2.
 This time the special number is 8.
 This time the special number is 4.
 This time the special number is 10.
 This time the special number is 6. Lucky you!!!
 This time the special number is 7.
 This time the special number is 6. Lucky you!!!
 This time the special number is 12. Lucky you!!!
 This time the special number is 6. Lucky you!!!
 This time the special number is 2.
 This time the special number is 11.
 This time the special number is 7.
 This time the special number is 11.
 This time the special number is 11.
 Finished: I choosed 15 random numbers, the total is 106.


Create a new paste based on this one


Comments: