3v4l.org

run code in 300+ PHP versions simultaneously
<?php // 請代入本平台提供的 hash 值並填入在單引號內 $txid = '799746d145f88f3d5514b40844e076cf1bcde7d1b167993a26ac7a641446e85d'; // 總共幾個大賞 $prize_count = 13; // 總共幾個籤數 $tag_count = 350; $dec = gmp_init($txid, 16); $prize_tmp = []; $prize_tmp_count = 0; $step_tmp = 100; $step = 1; $max_count = 100; try { while ($step <= $max_count) { $powResult = gmp_pow($step_tmp, $step); $div = gmp_div_q($dec, $powResult); $mod = gmp_mod($div, $tag_count); $prize_number = (int)gmp_strval($mod) + 1; if (!in_array($prize_number, $prize_tmp)) { $prize_tmp[] = $prize_number; $prize_tmp_count++; } if ($prize_tmp_count >= $prize_count) { break; } $step++; } echo implode(', ', $prize_tmp); } catch (\Exception $e) { echo $e->getMessage(); }
Output for 8.1.0 - 8.1.31, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13, 8.4.2
259, 346, 312, 130, 12, 253, 336, 249, 136, 54, 281, 35, 284
Output for 8.2.26, 8.3.14, 8.4.1
Fatal error: Uncaught ValueError: base and exponent overflow in /in/rD2S4:24 Stack trace: #0 /in/rD2S4(24): gmp_pow(100, 10) #1 {main} thrown in /in/rD2S4 on line 24
Process exited with code 255.

preferences:
43.91 ms | 407 KiB | 5 Q