(1) Generate 1000 integers of different multiples of 3 and store them in the file a.txt, one number per line;
(2) Generate 1000 integers of different multiples of 5 and store them in the file b.txt, one number per line;
(3) Please tell me the number of the same numbers in a.txt and b.txt, and list them
The flaw is that there is no weight judgment, but the range is given to 1 million, so the probability should be very low
<?php
$a = fopen('a.txt', 'w ');
$b = fopen('b.txt', 'w');
for($i = 0; $i < 1000; $i ) {
fwrite($a, getResult(3) . "\r\n");
fwrite($b, getResult(5) . "\r\n");
}
function getResult($num){
return $num * mt_rand(1, 1000000);
}